From: Steve Sutton Date: Fri, 29 Jun 2018 13:48:51 +0000 (-0400) Subject: Update front registration to work better in mobile view. X-Git-Tag: v1.0.6^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=d4091740d8ac5d329cc6c43fc988bb81ddb67767;p=WP-Plugins%2Fglm-member-db-registrations.git Update front registration to work better in mobile view. When adding attendees users have to scroll down to the submit and cancel buttons. When the form is removed it seems to bring them down to the bottom of the page. Saving the scroll position of the screen so when the submit or cancel we can place them back to the last position. --- diff --git a/js/frontRegApp.js b/js/frontRegApp.js index e946ffb..7bbdc4e 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -944,13 +944,16 @@ app.Views.Front.RegTime = Backbone.View.extend({ // add new account addNewAccount: function(){ if ( app.checkForMaxAttendees() === true ) { - alert( app.attendeePlurCapTerm + ' are currently limited to ' + app.attendeeMaxPerReg + ' per submission for this ' + app.eventCapTerm + '!'); + alert( 'You\'re only allowed to have ' + app.attendeeMaxPerReg + ' ' + app.attendeePlurCapTerm + ' per Registration!' ); return; } // check for the lock if ( app.checkForEditLock() === true ) { return; } + // Save the current screen position for Y + regPositionX = 0; + regPositionY = document.documentElement.scrollTop; this.$('.glm-add-new-account').hide(); // Create the new Registrant View if ( app.timeSpecific ) { @@ -1050,6 +1053,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ },{ wait: true, error: this.errorCallback }); this.$('.glm-add-new-account').show(); + window.scrollTo( regPositionX, regPositionY ); this.newRegAccount.destroy(); this.newRegAccountView.remove(); app.regEventLock = false; @@ -1071,6 +1075,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ // cancel add new registrant cancelAddNew: function(){ this.$('.glm-add-new-account').show(); + window.scrollTo( regPositionX, regPositionY ); this.newRegAccount.destroy(); this.newRegAccountView.remove(); app.regEventLock = false; diff --git a/js/views/front/regTime.js b/js/views/front/regTime.js index c10f18f..71b4a5d 100644 --- a/js/views/front/regTime.js +++ b/js/views/front/regTime.js @@ -54,6 +54,9 @@ app.Views.Front.RegTime = Backbone.View.extend({ if ( app.checkForEditLock() === true ) { return; } + // Save the current screen position for Y + regPositionX = 0; + regPositionY = document.documentElement.scrollTop; this.$('.glm-add-new-account').hide(); // Create the new Registrant View if ( app.timeSpecific ) { @@ -153,6 +156,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ },{ wait: true, error: this.errorCallback }); this.$('.glm-add-new-account').show(); + window.scrollTo( regPositionX, regPositionY ); this.newRegAccount.destroy(); this.newRegAccountView.remove(); app.regEventLock = false; @@ -174,6 +178,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ // cancel add new registrant cancelAddNew: function(){ this.$('.glm-add-new-account').show(); + window.scrollTo( regPositionX, regPositionY ); this.newRegAccount.destroy(); this.newRegAccountView.remove(); app.regEventLock = false; diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index a254a1c..91ff944 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -492,6 +492,8 @@ var ajaxUrl = '{$ajaxUrl}?action=glm_members_admin_ajax'; var thisPageUrl = '{$thisUrl}'; var nextPageUrl = '{$thisUrl}?page=cart'; var customFieldActive = '{$customfieldActive}'; +var regPositionX = 0; +var regPositionY = 0; var app = { Models: { Front: {}, Admin: {} }, Collections: { Front: {}, Admin: {} },