diff --git a/app/assets/javascripts/stick-to-window-when-scrolling.js b/app/assets/javascripts/stick-to-window-when-scrolling.js index e15bddfa4..bcc413084 100644 --- a/app/assets/javascripts/stick-to-window-when-scrolling.js +++ b/app/assets/javascripts/stick-to-window-when-scrolling.js @@ -272,6 +272,9 @@ this.CSS_SELECTOR = selector; this.STOP_PADDING = 10; }; + Sticky.prototype.setMode = function (mode) { + _mode = mode; + }; Sticky.prototype.getWindowDimensions = function () { return { height: $(global).height(), @@ -360,7 +363,7 @@ } }; // Recalculate stored dimensions for all sticky elements - Sticky.prototype.recalculate = function (opts) { + Sticky.prototype.recalculate = function () { var self = this; var onSyncComplete = function () { self.setEvents(); @@ -371,8 +374,6 @@ self.setElementPositions(); }; - if ((opts !== undefined) && ('mode' in opts)) { _mode = opts.mode; } - this.syncWithDOM(onSyncComplete); }; Sticky.prototype.setElWidth = function (el) { @@ -493,8 +494,8 @@ }); } }; - Sticky.prototype.init = function (opts) { - this.recalculate(opts); + Sticky.prototype.init = function () { + this.recalculate(); }; Sticky.prototype.setEvents = function () { var self = this; diff --git a/app/assets/javascripts/templateFolderForm.js b/app/assets/javascripts/templateFolderForm.js index dcd91a5a1..b7b0cf43b 100644 --- a/app/assets/javascripts/templateFolderForm.js +++ b/app/assets/javascripts/templateFolderForm.js @@ -144,9 +144,12 @@ state => (state.key === this.currentState ? this.$stickyBottom.append(state.$el) : state.$el.detach()) ); - // make sticky JS recalculate its cache of the element's position // use dialog mode for states which contain more than one form control - GOVUK.stickAtBottomWhenScrolling.recalculate({ 'mode': 'dialog' }); + if (['move-to-existing-folder', 'add-new-template'].includes(this.currentState)) { + GOVUK.stickAtBottomWhenScrolling.setMode('dialog'); + } + // make sticky JS recalculate its cache of the element's position + GOVUK.stickAtBottomWhenScrolling.recalculate(); }; this.nothingSelectedButtons = $(`