1function containerModule(data) { 2 Module.call(this, data); 3} 4 5inheritPrototype(containerModule, Module); 6 7containerModule.prototype.bindEvents = function () { 8 Module.prototype.bindEvents.call(this); 9 10 if(this.isSticky()) { 11 this.bindStickyMode(); 12 } 13}; 14 15containerModule.prototype.onAddedToStage = function () { 16 Module.prototype.onAddedToStage.call(this); 17 18 this.decorateContainer(); 19}; 20 21containerModule.prototype.decorateContainer = function () { 22 if(this.hasStyles()){ 23 var styles = this.getStyles(); 24 for(var viewport in styles){ 25 if(styles.hasOwnProperty(viewport)){ 26 var viewportStyles = styles[viewport]; 27 if(typeof viewportStyles === 'object' && viewportStyles !== null && viewportStyles.hasOwnProperty('container-display')){ 28 var containerDisplayValues = viewportStyles['container-display']; 29 if(typeof containerDisplayValues === 'object' && containerDisplayValues !== null && Array.isArray(containerDisplayValues) && containerDisplayValues.length > 0){ 30 var containerDisplay = containerDisplayValues[0]; 31 if(typeof containerDisplay === 'object' && containerDisplay !== null && containerDisplay.hasOwnProperty('value')){ 32 if(containerDisplay.value === 'flex'){ 33 this.markContainerFlex(viewport); 34 } 35 else{ 36 this.markContainerDefault(viewport); 37 } 38 } 39 } 40 } 41 } 42 } 43 } 44}; 45 46containerModule.prototype.markContainerFlex = function (viewport) { 47 this.getContainerHandler().addClass('display-flex-' + viewport); 48}; 49 50containerModule.prototype.markContainerDefault = function (viewport) { 51 this.getContainerHandler().addClass('display-default-' + viewport); 52}; 53 54containerModule.prototype.getContainerHandler = function () { 55 return this.getElement().find('> .bluetrix-container'); 56}; 57 58containerModule.prototype.bindStickyMode = function () { 59 var self = this; 60 61 this.stickyActive = false; 62 this.stickyClone = null; 63 this.stickyButtonContainer = null; 64 65 $(window).on('scroll', function () { 66 self.initSticky(); 67 }); 68 69 $(window).on('resize', function () { 70 self.initSticky(); 71 self.updateSticky(); 72 }); 73 74 this.markSticky(); 75 this.initSticky(); 76 this.updateSticky(); 77 this.onBindStickyMode(); 78}; 79 80containerModule.prototype.onBindStickyMode = function () {}; 81 82containerModule.prototype.markSticky = function () { 83 this.element.addClass('sticky-mode'); 84}; 85 86containerModule.prototype.initSticky = function () { 87 if(this.isMobileViewportSize() && this.isStickyOnMobileAllTime()){ 88 if(!this.isStickyActive()){ 89 this.createSticky(); 90 } 91 } 92 else { 93 if (this.getWindowScrollTop() >= this.getElementOffset() && !this.isStickyActive()) { 94 this.createSticky(); 95 } 96 else if (this.getWindowScrollTop() < this.getElementOffset() && this.isStickyActive()) { 97 this.destroySticky(); 98 } 99 } 100}; 101 102containerModule.prototype.updateSticky = function () { 103 if(this.isStickyActive()){ 104 this.resizeSticky(); 105 } 106}; 107 108containerModule.prototype.createSticky = function () { 109 this.stickyClone = this.element.clone(); 110 this.stickyClone.addClass('sticky-placeholder'); 111 if(this.isStickyOnMobileAllTime()){ 112 this.stickyClone.addClass('sticky-mobile-force-placeholder'); 113 } 114 this.stickyClone.insertAfter(this.element); 115 116 this.updateStickyParameters(); 117 this.element.addClass('sticky-position'); 118 119 this.createStickyButton(); 120 if (this.isShowCloseStickyButton()) { 121 this.createCloseStickyButton(); 122 } 123 124 this.stickyActive = true; 125}; 126 127containerModule.prototype.createStickyButton = function () { 128 var stickyButton = $('<button>').addClass('btn btn-success sticky-button'); 129 130 if (this.hasStickyCloseButtonText()) { 131 stickyButton.append( 132 $('<span>').addClass('sticky-button-text visible-on-close').text(this.getStickyButtonText()), 133 $('<span>').addClass('sticky-button-text visible-on-open').text(this.getStickyCloseButtonText()) 134 ) 135 } else { 136 stickyButton.text(this.getStickyButtonText()); 137 } 138 139
140 this.stickyButtonContainer = $('<div>').addClass('sticky-button-container').append(stickyButton); 141 this.element.append(this.stickyButtonContainer); 142 this.bindEventsToStickyButton(); 143}; 144 145containerModule.prototype.isShowCloseStickyButton = function() { 146 var set = this.getSettings(); 147 148 return set.hasOwnProperty('showStickyCloseButton') && -(-(set.showStickyCloseButton)) === 1; 149}; 150 151containerModule.prototype.createCloseStickyButton = function() { 152 if (this.stickyButtonContainer) { 153 this.stickyButtonContainer.append( 154 $('<button>').addClass('btn btn-close sticky-close-button').append( 155 $('<span>').addClass('fa fa-close') 156 ) 157 ) 158 } 159}; 160 161containerModule.prototype.bindEventsToStickyButton = function () { 162 var self = this; 163 164 this.stickyButtonContainer.on('click', '.sticky-button', function(){ 165 self.toggleSticky(); 166 }); 167 168 if (this.isShowCloseStickyButton()) { 169 this.stickyButtonContainer.on('click', '.sticky-close-button', function () { 170 self.hideSticky(); 171 }); 172 } 173}; 174 175containerModule.prototype.destroySticky = function () { 176 this.element.removeAttr('style'); 177 this.element.removeClass('sticky-position sticky-hidden sticky-visible'); 178 179 this.stickyClone.remove(); 180 this.stickyClone = null; 181 182 this.destroyStickyButton(); 183 184 this.stickyActive = false; 185}; 186 187containerModule.prototype.destroyStickyButton = function () { 188 this.stickyButtonContainer.remove(); 189 this.stickyButtonContainer = null; 190}; 191 192containerModule.prototype.toggleSticky = function () { 193 if(this.isStickyVisible()){ 194 this.hideSticky(); 195 } 196 else{ 197 this.showSticky(); 198 } 199}; 200 201containerModule.prototype.isStickyVisible = function () { 202 return this.element.hasClass('sticky-visible'); 203}; 204 205containerModule.prototype.showSticky = function () { 206 this.element.removeClass('sticky-hidden').addClass('sticky-visible'); 207 this.onShowSticky(); 208}; 209 210containerModule.prototype.onShowSticky = function () {}; 211 212containerModule.prototype.hideSticky = function () { 213 this.element.removeClass('sticky-visible').addClass('sticky-hidden'); 214 this.onHideSticky(); 215}; 216 217containerModule.prototype.onHideSticky = function () {}; 218 219containerModule.prototype.updateStickyParameters = function () { 220 var parameter = this.getParametersToStickyElement(); 221 222 this.element.css({ 223 left: parameter.left, 224 width: parameter.width 225 }); 226}; 227 228containerModule.prototype.getParametersToStickyElement = function () { 229 return { 230 left: this.isStickyActive() ? this.stickyClone.offset().left : this.element.offset().left, 231 width: this.isStickyActive() ? this.stickyClone.outerWidth() : this.element.outerWidth() 232 }; 233}; 234 235containerModule.prototype.resizeSticky = function () { 236 this.updateStickyParameters(); 237}; 238 239containerModule.prototype.isStickyActive = function () { 240 return this.stickyActive; 241}; 242 243containerModule.prototype.getElementOffset = function () { 244 return this.isStickyActive() ? (this.stickyClone.offset().top + this.stickyClone.height()) : (this.element.offset().top + this.element.height()); 245}; 246 247containerModule.prototype.getWindowScrollTop = function () { 248 return $(window).scrollTop(); 249}; 250 251containerModule.prototype.isSticky = function () { 252 var set = this.getSettings(); 253 return set.hasOwnProperty('isSticky') && -(-(set.isSticky)) === 1; 254}; 255 256containerModule.prototype.getStickyButtonText = function () { 257 var set = this.getSettings(); 258 return set.hasOwnProperty('stickyButtonText') ? set.stickyButtonText : ''; 259}; 260 261containerModule.prototype.getStickyCloseButtonText = function () { 262 var set = this.getSettings(); 263 return set.hasOwnProperty('stickyCloseButtonText') ? set.stickyCloseButtonText : undefined; 264}; 265 266containerModule.prototype.hasStickyCloseButtonText = function() { 267 var text = this.getStickyCloseButtonText(); 268 return typeof text === 'string' && text !== ''; 269}; 270 271containerModule.prototype.isStickyOnMobileAllTime = function () { 272 var set = this.getSettings(); 273 return set.hasOwnProperty('isStickyOnMobileAllTime') && -(-(set.isStickyOnMobileAllTime)) === 1; 274}; 275 276containerModule.prototype.isMobileViewportSize = function () { 277 return $(window).width() < 767; 278};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.