1/** 2 * Copyright ETS Software Technology Co., Ltd 3 * 4 * NOTICE OF LICENSE 5 * 6 * This file is not open source! Each license that you purchased is only available for 1 website only. 7 * If you want to use this file on more websites (or projects), you need to purchase additional licenses. 8 * You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party. 9 * 10 * DISCLAIMER 11 * 12 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer 13 * versions in the future. 14 * 15 * @author ETS Software Technology Co., Ltd 16 * @copyright ETS Software Technology Co., Ltd 17 * @license Valid for 1 website (or project) for each purchase of license 18 */ 19 20+function ($) { 21 'use strict'; 22 23 // MODAL CLASS DEFINITION 24 // ====================== 25 26 var ETSModal = function (element, options) { 27 this.options = options 28 this.$body = $(document.body) 29 this.$element = $(element) 30 this.$backdrop = 31 this.isShown = null 32 this.scrollbarWidth = 0 33 34 if (this.options.remote) { 35 this.$element 36 .find('.ets-rv-modal-content') 37 .load(this.options.remote, $.proxy(function () { 38 this.$element.trigger('loaded.bs.ets-rv-modal') 39 }, this)) 40 } 41 } 42 43 ETSModal.DEFAULTS = { 44 backdrop: true, 45 keyboard: true, 46 show: true 47 } 48 49 ETSModal.prototype.toggle = function (_relatedTarget) { 50 return this.isShown ? this.hide() : this.show(_relatedTarget) 51 } 52 53 ETSModal.prototype.show = function (_relatedTarget) { 54 var that = this 55 var e = $.Event('show.bs.ets-rv-modal', { relatedTarget: _relatedTarget }) 56 57 this.$element.trigger(e) 58 59 if (this.isShown || e.isDefaultPrevented()) return 60 61 this.isShown = true 62 63 this.checkScrollbar() 64 this.$body.addClass('ets-rv-modal-open') 65 66 this.setScrollbar() 67 this.escape() 68 69 this.$element.on('click.dismiss.bs.ets-rv-modal', '[data-dismiss="ets-rv-modal"]', $.proxy(this.hide, this)) 70 71 this.backdrop(function () { 72 var transition = $.support.transition && that.$element.hasClass('fade') 73 74 if (!that.$element.parent().length) { 75 that.$element.appendTo(that.$body) // don't move modals dom position 76 } 77 78 that.$element 79 .show() 80 .scrollTop(0) 81 82 if (transition) { 83 that.$element[0].offsetWidth // force reflow 84 } 85 86 that.$element 87 .addClass('in') 88 .attr('aria-hidden', false) 89 90 that.enforceFocus() 91 92 var e = $.Event('shown.bs.ets-rv-modal', { relatedTarget: _relatedTarget }) 93 94 transition ? 95 that.$element.find('.ets-rv-modal-dialog') // wait for modal to slide in 96 .one($.support.transition.end, function () { 97 that.$element.trigger('focus').trigger(e) 98 }) 99 .emulateTransitionEnd(300) : 100 that.$element.trigger('focus').trigger(e) 101 }) 102 } 103 104 ETSModal.prototype.hide = function (e) { 105 if (e) e.preventDefault() 106 107 e = $.Event('hide.bs.ets-rv-modal') 108 109 this.$element.trigger(e) 110 111 if (!this.isShown || e.isDefaultPrevented()) return 112 113 this.isShown = false 114 115 this.$body.removeClass('ets-rv-modal-open') 116 117 this.resetScrollbar() 118 this.escape() 119 120 $(document).off('focusin.bs.ets-rv-modal') 121 122 this.$element 123 .removeClass('in') 124 .attr('aria-hidden', true) 125 .off('click.dismiss.bs.ets-rv-modal') 126 127 $.support.transition && this.$element.hasClass('fade') ? 128 this.$element 129 .one($.support.transition.end, $.proxy(this.hideModal, this)) 130 .emulateTransitionEnd(300) : 131 this.hideModal() 132 } 133 134 ETSModal.prototype.enforceFocus = function () { 135 $(document) 136 .off('focusin.bs.ets-rv-modal') // guard against infinite focus loop 137 .on('focusin.bs.ets-rv-modal', $.proxy(function (e) { 138 if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { 139 this.$element.trigger('focus') 140 } 141 }, this)) 142 } 143 144 ETSModal.prototype.escape = function () { 145 if (this.isShown && this.options.keyboard) { 146 this.$element.on('keyup.dismiss.bs.ets-rv-modal', $.proxy(function (e) {
147 e.which == 27 && this.hide() 148 }, this)) 149 } else if (!this.isShown) { 150 this.$element.off('keyup.dismiss.bs.ets-rv-modal') 151 } 152 } 153 154 ETSModal.prototype.hideModal = function () { 155 var that = this 156 this.$element.hide() 157 this.backdrop(function () { 158 that.$element.trigger('hidden.bs.ets-rv-modal') 159 }) 160 } 161 162 ETSModal.prototype.removeBackdrop = function () { 163 this.$backdrop && this.$backdrop.remove() 164 this.$backdrop = null 165 } 166 167 ETSModal.prototype.backdrop = function (callback) { 168 var that = this 169 var animate = this.$element.hasClass('fade') ? 'fade' : '' 170 171 if (this.isShown && this.options.backdrop) { 172 var doAnimate = $.support.transition && animate 173 174 this.$backdrop = $('<div class="ets-rv-modal-backdrop ' + animate + '" />') 175 .appendTo(this.$body) 176 177 this.$element.on('click.dismiss.bs.ets-rv-modal', $.proxy(function (e) { 178 if (e.target !== e.currentTarget) return 179 this.options.backdrop == 'static' 180 ? this.$element[0].focus.call(this.$element[0]) 181 : this.hide.call(this) 182 }, this)) 183 184 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow 185 186 this.$backdrop.addClass('in') 187 188 if (!callback) return 189 190 doAnimate ? 191 this.$backdrop 192 .one($.support.transition.end, callback) 193 .emulateTransitionEnd(150) : 194 callback() 195 196 } else if (!this.isShown && this.$backdrop) { 197 this.$backdrop.removeClass('in') 198 199 var callbackRemove = function() { 200 that.removeBackdrop() 201 callback && callback() 202 } 203 $.support.transition && this.$element.hasClass('fade') ? 204 this.$backdrop 205 .one($.support.transition.end, callbackRemove) 206 .emulateTransitionEnd(150) : 207 callbackRemove() 208 209 } else if (callback) { 210 callback() 211 } 212 } 213 214 ETSModal.prototype.checkScrollbar = function () { 215 if (document.body.clientWidth >= window.innerWidth) return 216 this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar() 217 } 218 219 ETSModal.prototype.setScrollbar = function () { 220 var bodyPad = parseInt(this.$body.css('padding-right') || 0) 221 if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth) 222 } 223 224 ETSModal.prototype.resetScrollbar = function () { 225 this.$body.css('padding-right', '') 226 } 227 228 ETSModal.prototype.measureScrollbar = function () { // thx walsh 229 var scrollDiv = document.createElement('div') 230 scrollDiv.className = 'ets-rv-modal-scrollbar-measure' 231 this.$body.append(scrollDiv) 232 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth 233 this.$body[0].removeChild(scrollDiv) 234 return scrollbarWidth 235 } 236 237 238 // MODAL PLUGIN DEFINITION 239 // ======================= 240 241 var old = $.fn.ETSModal 242 243 $.fn.ETSModal = function (option, _relatedTarget) { 244 return this.each(function () { 245 var $this = $(this) 246 var data = $this.data('bs.ets-rv-modal') 247 var options = $.extend({}, ETSModal.DEFAULTS, $this.data(), typeof option == 'object' && option) 248 249 if (!data) $this.data('bs.ets-rv-modal', (data = new ETSModal(this, options))) 250 if (typeof option == 'string') data[option](_relatedTarget) 251 else if (options.show) data.show(_relatedTarget) 252 }) 253 } 254 255 $.fn.ETSModal.Constructor = ETSModal 256 257 258 // MODAL NO CONFLICT 259 // ================= 260 261 $.fn.ETSModal.noConflict = function () { 262 $.fn.ETSModal = old 263 return this 264 } 265 266 267 // MODAL DATA-API 268 // ============== 269 270 $(document).on('click.bs.ets-rv-modal.data-api', '[data-toggle="ets-rv-modal"]', function (e) { 271 var $this = $(this) 272 var href = $this.attr('href') 273 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 274 var option = $target.data('bs.ets-rv-modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) 275 276 if ($this.is('a')) e.preventDefault() 277 278 $target 279 .ETSModal(option, this) 280 .one('hide', function () { 281 $this.is(':visible') && $this.trigger('focus') 282 }) 283 }) 284 285}(jQuery);
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.