PageSourceSearch

https://www.pluscolor.es/modules/dynamicproduct/views/js/modal/jquery.modal.js

js pluscolor.es collected 2026-10-06 09:28:55 UTC 8,481 bytes, 262 lines download raw bytes

vendor: 8,481 bytes, lines 1-262
1/**
2* 2010-2015 Tuni-Soft
3*
4* NOTICE OF LICENSE
5*
6* This source file is subject to the Academic Free License (AFL 3.0)
7* It is available through the world-wide-web at this URL:
8* http://opensource.org/licenses/afl-3.0.php
9* If you did not receive a copy of the license and are unable to
10* obtain it through the world-wide-web, please send an email
11* to [email protected] so we can send you a copy immediately.
12*
13* DISCLAIMER
14*
15* Do not edit or add to this file if you wish to upgrade this module to newer
16* versions in the future. If you wish to customize the module for your
17* needs please refer to
18* http://doc.prestashop.com/display/PS15/Overriding+default+behaviors
19* for more information.
20*
21* @author    Tunis-Soft
22* @copyright 2010-2015 Tuni-Soft
23* @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
24*/
25
26/*
27    A simple jQuery modal (http://github.com/kylefox/jquery-modal)
28    Version 0.8.0
29*/
30
31(function (factory) {
32  // Making your jQuery plugin work better with npm tools
33  // http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm
34  if(typeof module === "object" && typeof module.exports === "object") {
35    factory(require("jquery"), window, document);
36  }
37  else {
38    factory(jQuery, window, document);
39  }
40}(function($, window, document, undefined) {
41
42  var modals = [],
43      getCurrent = function() {
44        return modals.length ? modals[modals.length - 1] : null;
45      },
46      selectCurrent = function() {
47        var i,
48            selected = false;
49        for (i=modals.length-1; i>=0; i--) {
50          if (modals[i].$blocker) {
51            modals[i].$blocker.toggleClass('current',!selected).toggleClass('behind',selected);
52            selected = true;
53          }
54        }
55      };
56
57  $.dp_modal = function(el, options) {
58    var remove, target;
59    this.$body = $('body');
60    this.options = $.extend({}, $.dp_modal.defaults, options);
61    this.options.doFade = !isNaN(parseInt(this.options.fadeDuration, 10));
62    this.$blocker = null;
63    if (this.options.closeExisting)
64      while ($.dp_modal.isActive())
65        $.dp_modal.close(); // Close any open modals.
66    modals.push(this);
67    if (el.is('a')) {
68      target = el.attr('href');
69      //Select element by id from href
70      if (/^#/.test(target)) {
71        this.$elm = $(target);
72        if (this.$elm.length !== 1) return null;
73        this.$body.append(this.$elm);
74        this.open();
75      //AJAX
76      } else {
77        this.$elm = $('<div>');
78        this.$body.append(this.$elm);
79        remove = function(event, modal) { modal.elm.remove(); };
80        this.showSpinner();
81        el.trigger($.dp_modal.AJAX_SEND);
82        $.get(target).done(function(html) {
83          if (!$.dp_modal.isActive()) return;
84          el.trigger($.dp_modal.AJAX_SUCCESS);
85          var current = getCurrent();
86          current.$elm.empty().append(html).on($.dp_modal.CLOSE, remove);
87          current.hideSpinner();
88          current.open();
89          el.trigger($.dp_modal.AJAX_COMPLETE);
90        }).fail(function() {
91          el.trigger($.dp_modal.AJAX_FAIL);
92          var current = getCurrent();
93          current.hideSpinner();
94          modals.pop(); // remove expected modal from the list
95          el.trigger($.dp_modal.AJAX_COMPLETE);
96        });
97      }
98    } else {
99      this.$elm = el;
100      this.$body.append(this.$elm);
101      this.open();
102    }
103  };
104
105  $.dp_modal.prototype = {
106    constructor: $.dp_modal,
107
108    open: function() {
109      var m = this;
110      this.block();
111      if(this.options.doFade) {
112        setTimeout(function() {
113          m.show();
114        }, this.options.fadeDuration * this.options.fadeDelay);
115      } else {
116        this.show();
117      }
118      $(document).off('keydown.modal').on('keydown.modal', function(event) {
119        var current = getCurrent();
120        if (event.which == 27 && current.options.escapeClose) current.close();
121      });
122      if (this.options.clickClose)
123        this.$blocker.click(function(e) {
124          if (e.target==this)
125            $.dp_modal.close();
126        });
127    },
128
129    close: function() {
130      modals.pop();
131      this.unblock();
132      this.hide();
133      if (!$.dp_modal.isActive())
134        $(document).off('keydown.modal');
135    },
136
137    block: function() {
138      this.$elm.trigger($.dp_modal.BEFORE_BLOCK, [this._ctx()]);
139      this.$blocker = $('<div class="jquery-modal blocker current"></div>').appendTo(this.$body);
140      selectCurrent();
141      if(this.options.doFade) {
142        this.$blocker.css('opacity',0).animate({opacity: 1}, this.options.fadeDuration);
143      }
144      this.$elm.trigger($.dp_modal.BLOCK, [this._ctx()]);
145    },
146
147    unblock: function(now) {
148      if (!now && this.options.doFade)
149        this.$blocker.fadeOut(this.options.fadeDuration, this.unblock.bind(this,true));
150      else {
151        this.$blocker.children().appendTo(this.$body);
152        this.$blocker.remove();
153        this.$blocker = null;
154        selectCurrent();
155      }
156    },
157
158    show: function() {
159      this.$elm.trigger($.dp_modal.BEFORE_OPEN, [this._ctx()]);
160      if (this.options.showClose) {
161        this.closeButton = $('<a href="#close-modal" rel="modal:close" class="close-modal ' + this.options.closeClass + '">' + this.options.closeText + '</a>');
162        this.$elm.append(this.closeButton);
163      }
164      this.$elm.addClass(this.options.dp_modalClass).appendTo(this.$blocker);
165      if(this.options.doFade) {
166        this.$elm.css('opacity',0).show().animate({opacity: 1}, this.options.fadeDuration);
167      } else {
168        this.$elm.show();
169      }
170      this.$elm.trigger($.dp_modal.OPEN, [this._ctx()]);
171    },
172
173    hide: function() {
174      this.$elm.trigger($.dp_modal.BEFORE_CLOSE, [this._ctx()]);
175      if (this.closeButton) this.closeButton.remove();
176      var _this = this;
177      if(this.options.doFade) {
178        this.$elm.fadeOut(this.options.fadeDuration, function () {
179          _this.$elm.trigger($.dp_modal.AFTER_CLOSE, [_this._ctx()]);
180        });
181      } else {
182        this.$elm.hide(0, function () {
183          _this.$elm.trigger($.dp_modal.AFTER_CLOSE, [_this._ctx()]);
184        });
185      }
186      this.$elm.trigger($.dp_modal.CLOSE, [this._ctx()]);
187    },
188
189    showSpinner: function() {
190      if (!this.options.showSpinner) return;
191      this.spinner = this.spinner || $('<div class="' + this.options.modalClass + '-spinner"></div>')
192        .append(this.options.spinnerHtml);
193      this.$body.append(this.spinner);
194      this.spinner.show();
195    },
196
197    hideSpinner: function() {
198      if (this.spinner) this.spinner.remove();
199    },
200
201    //Return context for custom events
202    _ctx: function() {
203      return { elm: this.$elm, $blocker: this.$blocker, options: this.options };
204    }
205  };
206
207  $.dp_modal.close = function(event) {
208    if (!$.dp_modal.isActive()) return;
209    if (event) event.preventDefault();
210    var current = getCurrent();
211    current.close();
212    return current.$elm;
213  };
214
215  // Returns if there currently is an active modal
216  $.dp_modal.isActive = function () {
217    return modals.length > 0;
218  }
219
220  $.dp_modal.getCurrent = getCurrent;
221
222  $.dp_modal.defaults = {
223    closeExisting: true,
224    escapeClose: true,
225    clickClose: true,
226    closeText: 'Close',
227    closeClass: '',
228    modalClass: "modal",
229    spinnerHtml: null,
230    showSpinner: true,
231    showClose: true,
232    fadeDuration: null,   // Number of milliseconds the fade animation takes.
233    fadeDelay: 1.0        // Point during the overlay's fade-in that the modal begins to fade in (.5 = 50%, 1.5 = 150%, etc.)
234  };
235
236  // Event constants
237  $.dp_modal.BEFORE_BLOCK = 'modal:before-block';
238  $.dp_modal.BLOCK = 'modal:block';
239  $.dp_modal.BEFORE_OPEN = 'modal:before-open';
240  $.dp_modal.OPEN = 'modal:open';
241  $.dp_modal.BEFORE_CLOSE = 'modal:before-close';
242  $.dp_modal.CLOSE = 'modal:close';
243  $.dp_modal.AFTER_CLOSE = 'modal:after-close';
244  $.dp_modal.AJAX_SEND = 'modal:ajax:send';
245  $.dp_modal.AJAX_SUCCESS = 'modal:ajax:success';
246  $.dp_modal.AJAX_FAIL = 'modal:ajax:fail';
247  $.dp_modal.AJAX_COMPLETE = 'modal:ajax:complete';
248
249  $.fn.dp_modal = function(options){
250    if (this.length === 1) {
251      new $.dp_modal(this, options);
252    }
253    return this;
254  };
255
256  // Automatically bind links with rel="modal:close" to, well, close the modal.
257  $(document).on('click.modal', 'a[rel~="modal:close"]', $.dp_modal.close);
258  $(document).on('click.modal', 'a[rel~="modal:open"]', function(event) {
259    event.preventDefault();
260    $(this).dp_modal();
261  });
262}));

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.