1/* 2 * Nivo Lightbox v1.2.0 3 * http://dev7studios.com/nivo-lightbox 4 * 5 * Copyright 2013, Dev7studios 6 * Free to use and abuse under the MIT license. 7 * http://www.opensource.org/licenses/mit-license.php 8 */ 9(function(e, t, n, r) { 10 function o(t, n) { 11 this.el = t; 12 this.$el = e(this.el); 13 this.options = e.extend({}, s, n); 14 this._defaults = s; 15 this._name = i; 16 this.init() 17 } 18 var i = "nivoLightbox", 19 s = { 20 effect: "fade", 21 theme: "default", 22 keyboardNav: true, 23 clickOverlayToClose: true, 24 onInit: function() {}, 25 beforeShowLightbox: function() {}, 26 afterShowLightbox: function(e) {}, 27 beforeHideLightbox: function() {}, 28 afterHideLightbox: function() {}, 29 onPrev: function(e) {}, 30 onNext: function(e) {}, 31 errorMessage: "The requested content cannot be loaded. Please try again later." 32 }; 33 o.prototype = { 34 init: function() { 35 var t = this; 36 if (!e("html").hasClass("nivo-lightbox-notouch")) e("html").addClass("nivo-lightbox-notouch"); 37 if ("ontouchstart" in n) e("html").removeClass("nivo-lightbox-notouch"); 38 this.$el.on("click", function(e) { 39 t.showLightbox(e) 40 }); 41 if (this.options.keyboardNav) { 42 e("body").off("keyup").on("keyup", function(n) { 43 var r = n.keyCode ? n.keyCode : n.which; 44 if (r == 27) t.destructLightbox(); 45 if (r == 37) e(".nivo-lightbox-prev").trigger("click"); 46 if (r == 39) e(".nivo-lightbox-next").trigger("click") 47 }) 48 } 49 this.options.onInit.call(this) 50 }, 51 showLightbox: function(t) { 52 var n = this, 53 r = this.$el; 54 var i = this.checkContent(r); 55 if (!i) return; 56 t.preventDefault(); 57 this.options.beforeShowLightbox.call(this); 58 var s = this.constructLightbox(); 59 if (!s) return; 60 var o = s.find(".nivo-lightbox-content"); 61 if (!o) return; 62 e("body").addClass("nivo-lightbox-body-effect-" + this.options.effect); 63 this.processContent(o, r); 64 if (this.$el.attr("data-lightbox-gallery")) { 65 var u = e('[data-lightbox-gallery="' + this.$el.attr("data-lightbox-gallery") + '"]'); 66 e(".nivo-lightbox-nav").show(); 67 e(".nivo-lightbox-prev").off("click").on("click", function(t) { 68 t.preventDefault(); 69 var i = u.index(r); 70 r = u.eq(i - 1); 71 if (!e(r).length) r = u.last(); 72 n.processContent(o, r); 73 n.options.onPrev.call(this, [r]) 74 }); 75 e(".nivo-lightbox-next").off("click").on("click", function(t) { 76 t.preventDefault(); 77 var i = u.index(r); 78 r = u.eq(i + 1); 79 if (!e(r).length) r = u.first(); 80 n.processContent(o, r); 81 n.options.onNext.call(this, [r]) 82 }) 83 } 84 setTimeout(function() { 85 s.addClass("nivo-lightbox-open"); 86 n.options.afterShowLightbox.call(this, [s]) 87 }, 1) 88 }, 89 checkContent: function(e) { 90 var t = this, 91 n = e.attr("href"), 92 r = n.match(/(youtube|youtu|vimeo)\.(com|be)\/(watch\?v=([\w-]+)|([\w-]+))/); 93 if (n.match(/\.(jpeg|jpg|gif|png)$/i) !== null) { 94 return true 95 } else if (r) { 96 return true 97 } else if (e.attr("data-lightbox-type") == "ajax") { 98 return true 99 } else if (n.substring(0, 1) == "#" && e.attr("data-lightbox-type") == "inline") { 100 return true 101 } else if (e.attr("data-lightbox-type") == "iframe") { 102 return true 103 } 104 return false 105 }, 106 processContent: function(n, r) { 107 var i = this, 108 s = r.attr("href"), 109 o = s.match(/(youtube|youtu|vimeo)\.(com|be)\/(watch\?v=([\w-]+)|([\w-]+))/); 110 n.html("").addClass("nivo-lightbox-loading"); 111 if (this.isHidpi() && r.attr("data-lightbox-hidpi")) { 112 s = r.attr("data-lightbox-hidpi") 113 } 114 if (s.match(/\.(jpeg|jpg|gif|png)$/i) !== null) { 115 var u = e("<img>", { 116 src: s 117 }); 118 u.one("load", function() { 119 var r = e('<div class="nivo-lightbox-image" />'); 120 r.append(u); 121 n.html(r).removeClass("nivo-lightbox-loading"); 122 r.css({ 123 "line-height": e(".nivo-lightbox-content").height() + "px", 124 height: e(".nivo-lightbox-content").height() + "px" 125 }); 126 e(t).resize(function() { 127 r.css({ 128 "line-height": e(".nivo-lightbox-content").height() + "px", 129 height: e(".nivo-lightbox-content").height() + "px" 130 }) 131 }) 132 }).each(function() { 133 if (this.complete) e(this).load() 134 }); 135 u.error(function() { 136 var t = e('<div class="nivo-lightbox-error"><p>' + i.options.errorMessage + "</p></div>"); 137 n.html(t).removeClass("nivo-lightbox-loading") 138 }) 139 } else if (o) { 140 var a = "", 141 f = "nivo-lightbox-video"; 142 if (o[1] == "youtube") { 143 a = "http://www.youtube.com/embed/" + o[4]; 144 f = "nivo-lightbox-youtube" 145 } 146 if (o[1] == "youtu") { 147 a = "http://www.youtube.com/embed/" + o[3]; 148 f = "nivo-lightbox-youtube" 149 } 150 if (o[1] == "vimeo") { 151 a = "http://player.vimeo.com/video/" + o[3]; 152 f = "nivo-lightbox-vimeo" 153 } 154 if (a) { 155 var l = e("<iframe>", { 156 src: a, 157 "class": f, 158 frameborder: 0, 159 vspace: 0, 160 hspace: 0, 161 scrolling: "auto" 162 }); 163 n.html(l); 164 l.load(function() { 165 n.removeClass("nivo-lightbox-loading") 166 }) 167 } 168 } else if (r.attr("data-lightbox-type") == "ajax") { 169 e.ajax({ 170 url: s, 171 cache: false, 172 success: function(r) { 173 var i = e('<div class="nivo-lightbox-ajax" />'); 174 i.append(r); 175 n.html(i).removeClass("nivo-lightbox-loading"); 176 if (i.outerHeight() < n.height()) { 177 i.css({ 178 position: "relative", 179 top: "50%", 180 "margin-top": -(i.outerHeight() / 2) + "px" 181 }) 182 } 183 e(t).resize(function() { 184 if (i.outerHeight() < n.height()) { 185 i.css({ 186 position: "relative", 187 top: "50%", 188 "margin-top": -(i.outerHeight() / 2) + "px" 189 }) 190 } 191 }) 192 }, 193 error: function() { 194 var t = e('<div class="nivo-lightbox-error"><p>' + i.options.errorMessage + "</p></div>"); 195 n.html(t).removeClass("nivo-lightbox-loading") 196 } 197 }) 198 } else if (s.substring(0, 1) == "#" && r.attr("data-lightbox-type") == "inline") { 199 if (e(s).length) { 200 var c = e('<div class="nivo-lightbox-inline" />'); 201 c.append(e(s).clone().show()); 202 n.html(c).removeClass("nivo-lightbox-loading"); 203 if (c.outerHeight() < n.height()) { 204 c.css({ 205 position: "relative", 206 top: "50%", 207 "margin-top": -(c.outerHeight() / 2) + "px" 208 }) 209 } 210 e(t).resize(function() { 211 if (c.outerHeight() < n.height()) { 212 c.css({ 213 position: "relative", 214 top: "50%", 215 "margin-top": -(c.outerHeight() / 2) + "px" 216 }) 217 } 218 }) 219 } else { 220 var h = e('<div class="nivo-lightbox-error"><p>' + i.options.errorMessage + "</p></div>"); 221 n.html(h).removeClass("nivo-lightbox-loading") 222 } 223 } else if (r.attr("data-lightbox-type") == "iframe") { 224 var p = e("<iframe>", { 225 src: s, 226 "class": "nivo-lightbox-item", 227 frameborder: 0, 228 vspace: 0, 229 hspace: 0, 230 scrolling: "auto" 231 }); 232 n.html(p); 233 p.load(function() { 234 n.removeClass("nivo-lightbox-loading") 235 }) 236 } else { 237 return false 238 } 239 if (r.attr("title")) { 240 var d = e("<span>", { 241 "class": "nivo-lightbox-title" 242 }); 243 d.text(r.attr("title")); 244 e(".nivo-lightbox-title-wrap").html(d) 245 } else { 246 e(".nivo-lightbox-title-wrap").html("") 247 } 248 }, 249 constructLightbox: function() {
250 if (e(".nivo-lightbox-overlay").length) return e(".nivo-lightbox-overlay"); 251 var t = e("<div>", { 252 "class": "nivo-lightbox-overlay nivo-lightbox-theme-" + this.options.theme + " nivo-lightbox-effect-" + this.options.effect 253 }); 254 var n = e("<div>", { 255 "class": "nivo-lightbox-wrap" 256 }); 257 var r = e("<div>", { 258 "class": "nivo-lightbox-content" 259 }); 260 var i = e('<a href="#" class="nivo-lightbox-nav nivo-lightbox-prev">Previous</a><a href="#" class="nivo-lightbox-nav nivo-lightbox-next">Next</a>'); 261 var s = e('<a href="#" class="nivo-lightbox-close" title="Close">Close</a>'); 262 var o = e("<div>", { 263 "class": "nivo-lightbox-title-wrap" 264 }); 265 var u = 0; 266 if (u) t.addClass("nivo-lightbox-ie"); 267 n.append(r); 268 n.append(o); 269 t.append(n); 270 t.append(i); 271 t.append(s); 272 e("body").append(t); 273 var a = this; 274 if (a.options.clickOverlayToClose) { 275 t.on("click", function(t) { 276 if (t.target === this || e(t.target).hasClass("nivo-lightbox-content") || e(t.target).hasClass("nivo-lightbox-image")) { 277 a.destructLightbox() 278 } 279 }) 280 } 281 s.on("click", function(e) { 282 e.preventDefault(); 283 a.destructLightbox() 284 }); 285 return t 286 }, 287 destructLightbox: function() { 288 var t = this; 289 this.options.beforeHideLightbox.call(this); 290 e(".nivo-lightbox-overlay").removeClass("nivo-lightbox-open"); 291 e(".nivo-lightbox-nav").hide(); 292 e("body").removeClass("nivo-lightbox-body-effect-" + t.options.effect); 293 var n = 0; 294 if (n) { 295 e(".nivo-lightbox-overlay iframe").attr("src", " "); 296 e(".nivo-lightbox-overlay iframe").remove() 297 } 298 e(".nivo-lightbox-prev").off("click"); 299 e(".nivo-lightbox-next").off("click"); 300 e(".nivo-lightbox-content").empty(); 301 this.options.afterHideLightbox.call(this) 302 }, 303 isHidpi: function() { 304 var e = "(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)"; 305 if (t.devicePixelRatio > 1) return true; 306 if (t.matchMedia && t.matchMedia(e).matches) return true; 307 return false 308 } 309 }; 310 e.fn[i] = function(t) { 311 return this.each(function() { 312 if (!e.data(this, i)) { 313 e.data(this, i, new o(this, t)) 314 } 315 }) 316 } 317})(jQuery, window, document)
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.