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