1 2"use strict"; 3 4 5 6/* -------------------------------------------------------------------------* 7 * LIGHTBOX SLIDER 8 * -------------------------------------------------------------------------*/ 9 function OT_lightbox_slider(el,side) { 10 11 if(el.attr('rel')%8==0 && side == "right") { 12 //carousel('right'); 13 } 14 15 if(el.attr('rel')%7==0 && side == "left") { 16 //carousel('left'); 17 } 18 19 } 20 21/* -------------------------------------------------------------------------* 22 * GALLERY 23 * -------------------------------------------------------------------------*/ 24 25 var OT_gallery = { 26 27 //the main image location 28 main_image : function (element) { 29 if(element) { 30 return element.closest('.ot-slide-item').find(".ot-gallery-image"); 31 } else { 32 return jQuery(".ot-gallery-image"); 33 } 34 35 }, 36 37 //next button location 38 next_button : function (element) { 39 return element.closest('.ot-slide-item').find(".next"); 40 }, 41 42 //previous button location 43 prev_button : function (element) { 44 return element.closest('.ot-slide-item').find(".prev"); 45 }, 46 47 //next image number 48 next_image : function (element) { 49 return element.closest('.ot-slide-item').find(".next-image"); 50 }, 51 52 //the opened image number 53 opened_image : function (element) { 54 return OT_gallery.main_image(element).attr("data-id"); 55 }, 56 57 //the active thumbnail 58 active_thumb : function (element) { 59 return jQuery(".the-thumbs a"); 60 }, 61 62 //total image count 63 total_img : function (element) { 64 return jQuery(".the-thumbs a.gal-thumbs").size(); 65 }, 66 67 //lightbox 68 a_click : function (adminUrl, gallery_id) { 69 OT_gallery.swipe(100); 70 71 //if images loaded 72 if(OT_gallery.main_image().attr("src")=="") { 73 OT_gallery.main_image().load(function(){ 74 OT_gallery.main_image().fadeIn('slow'); 75 //gallery 76 jQuery(".waiter").removeClass("loading").addClass("loaded"); 77 }); 78 } else { 79 OT_gallery.main_image().fadeIn('slow'); 80 //gallery 81 jQuery(".waiter").removeClass("loading").addClass("loaded"); 82 } 83 84 85 //set active thumbnail by page load in lightbox 86 jQuery.each(OT_gallery.active_thumb(), function() { 87 jQuery(this).removeClass("active"); 88 if(jQuery(this).attr("data-nr") == OT_gallery.opened_image(jQuery(this))) { 89 jQuery(this).addClass("active"); 90 } 91 92 }); 93 94 //show the loading after click
95 jQuery('.ot-slide-item').on( "click", ".next, .prev, .gal-thumbs", function() { 96 OT_gallery.Loading(jQuery(this),adminUrl,false); 97 98 }); 99 100 //load the next image 101 jQuery('.ot-slide-item').on( "click", ".next", function() { 102 OT_gallery.NextImage(jQuery(this)); 103 }); 104 105 //load the previous image 106 jQuery('.ot-slide-item').on( "click", ".prev", function() { 107 OT_gallery.PrevImage(jQuery(this)); 108 }); 109 110 //load the clicked thumbnail 111 jQuery('.ot-slide-item').on( "click", ".gal-thumbs", function() { 112 113 var next = jQuery(this).attr("rel"); 114 115 if(jQuery(this).attr("rel")!=OT_gallery.total_img()) { 116 OT_gallery.next_button(jQuery(this)).attr("rel", parseInt(next)+1); 117 OT_gallery.prev_button(jQuery(this)).attr("rel", parseInt(next)-1); 118 OT_gallery.next_image(jQuery(this)).attr("data-next", parseInt(next)+1); 119 OT_gallery.main_image(jQuery(this)).attr("data-id", parseInt(next)); 120 } else { 121 OT_gallery.next_button(jQuery(this)).attr("rel",OT_gallery.total_img()); 122 OT_gallery.prev_button(jQuery(this)).attr("rel", parseInt(OT_gallery.total_img())-1); 123 OT_gallery.next_image(jQuery(this)).attr("data-next", OT_gallery.total_img()); 124 OT_gallery.main_image(jQuery(this)).attr("data-id", parseInt(next)); 125 126 } 127 if(jQuery(this).attr("rel")==1) { 128 OT_gallery.prev_button(jQuery(this)).attr("rel", 0); 129 OT_gallery.main_image(jQuery(this)).attr("data-id", parseInt(next)); 130 } 131 132 }); 133 134 //set active image after click for the next image
135 jQuery('.ot-slide-item').on( "click", ".next, .prev, .gal-thumbs", function() { 136 OT_gallery.Thumbs(jQuery(this)); 137 }); 138 139 140 }, 141 142 NextImage : function (clicked) { 143 OT_lightbox_slider(clicked,"right"); 144 145 if(parseInt(OT_gallery.total_img()) > OT_gallery.opened_image(clicked)) { 146 OT_gallery.main_image(clicked).attr("data-id", parseInt(OT_gallery.opened_image(clicked))+1); 147 OT_gallery.prev_button(clicked).attr("rel", parseInt(OT_gallery.prev_button(clicked).attr("rel"))+1); 148 } 149 if(parseInt(OT_gallery.total_img()) > parseInt(clicked.attr("rel"))) { 150 clicked.attr("rel", parseInt(clicked.attr("rel"))+1); 151 OT_gallery.next_image(clicked).attr("data-next", parseInt(clicked.attr("rel"))); 152 } 153 }, 154 155 PrevImage : function (clicked) { 156 OT_lightbox_slider(clicked,"left"); 157 158 if(parseInt(OT_gallery.opened_image(clicked)) > 1 && parseInt(OT_gallery.opened_image(clicked)) != jQuery(".next").attr("rel")) { 159 OT_gallery.next_button(clicked).attr("rel", parseInt(OT_gallery.next_button(clicked).attr("rel"))-1); 160 OT_gallery.next_image(clicked).attr("data-next", parseInt(OT_gallery.next_button(clicked).attr("rel"))); 161 } 162 if(parseInt(OT_gallery.opened_image(clicked)) > 1) { 163 clicked.attr("rel", parseInt(clicked.attr("rel"))-1); 164 OT_gallery.main_image(clicked).attr("data-id", parseInt(OT_gallery.opened_image(clicked))-1); 165 } 166 }, 167 168 Loading : function (clicked,adminUrl,swipe) {
169 var ID = jQuery('.ot-slide-item').attr("id"); 170 var clicked = clicked; 171 var next = clicked.attr("rel"); 172 var waiter = jQuery('.ot-slide-item').find('.waiter'); 173 var image = OT_gallery.main_image(clicked); 174 175 176 177 if( (parseInt(OT_gallery.opened_image(clicked)) < parseInt(OT_gallery.total_img()) || next!=parseInt(OT_gallery.total_img())) && next!=0 && next!=OT_gallery.opened_image(clicked)) { 178 waiter.removeClass("loaded"); 179 waiter.addClass("loading"); 180 181 jQuery.ajax({ 182 url:adminUrl, 183 type:"POST", 184 data:"action=load_next_image&gallery_id="+ID+"&next_image="+next, 185 success:function(results) { 186 image.attr("src", results); 187 //image resize 188 image.css("max-height", jQuery(window).height()+"px"); 189 image.load(function(){ 190 setTimeout(function () { 191 waiter.removeClass("loading"); 192 waiter.addClass("loaded"); 193 }, 800); 194 195 196 }); 197 jQuery(".numbers span.current").html(next); 198 } 199 }); 200 201 } 202 }, 203 204 Thumbs : function (clicked) { 205 206 jQuery.each(OT_gallery.active_thumb(), function() { 207 jQuery(this).removeClass("active"); 208 209 if(jQuery(this).attr("data-nr") == OT_gallery.opened_image(clicked)) { 210 jQuery(this).addClass("active"); 211 212 } 213 214 }); 215 216 217 }, 218 219 220 221 // swipe navigation 222 swipe : function (xx) { 223 224 (function(jQuery, undefined) { 225 226 var adminUrl = ot.adminUrl; 227 var wrap = jQuery('.waiter'), 228 slides = wrap.find('.image-big-gallery'), 229 230 width = wrap.width(); 231 232 // Listen for swipe events on slides, and use a custom 'activate' 233 // or next slide, and to keep the index up-to-date. The class 234 235 slides 236 237 .on('swipeleft', function(e) {
238 OT_gallery.Loading(jQuery('.ot-slide-item .next'),adminUrl,true); 239 OT_gallery.NextImage(jQuery('.ot-slide-item .next')); 240 OT_gallery.Thumbs(jQuery('.ot-slide-item .next')); 241 }) 242 243 .on('swiperight', function(e) { 244 OT_gallery.Loading(jQuery('.ot-slide-item .prev'),adminUrl,true); 245 OT_gallery.PrevImage(jQuery('.ot-slide-item .prev')); 246 OT_gallery.Thumbs(jQuery('.ot-slide-item .prev')); 247 }) 248 249 250 251 // The code below handles what happens before any swipe event is triggered. 252 // It makes the slides demo on this page work nicely, but really doesn't 253 // have much to do with demonstrating the swipe events themselves. For more 254 // on move events see: 255 // 256 // http://stephband.info/jquery.event.move 257 258 .on('movestart', function(e) { 259 // If the movestart heads off in a upwards or downwards 260 // direction, prevent it so that the browser scrolls normally. 261 if ((e.distX > e.distY && e.distX < -e.distY) || 262 (e.distX < e.distY && e.distX > -e.distY)) { 263 e.preventDefault(); 264 return; 265 } 266 267 // To allow the slide to keep step with the finger, 268 // temporarily disable transitions. 269 wrap.addClass('notransition'); 270 }) 271 272 .on('move', function(e) { 273 var left = xx * e.distX / width; 274 275 // Move slides with the finger 276 if (e.distX < 0) { 277 if (slides) { 278 slides.css("left", left + '%'); 279 slides.css("left", (left+0)+'%'); 280 } 281 else { 282 slides.css("left", left/4 + '%'); 283 } 284 } 285 if (e.distX > 0) { 286 if (slides) { 287 slides.css("left", left + '%'); 288 slides.css("left", (left-0)+'%'); 289 } 290 else { 291 slides.css("left", left/5 + '%'); 292 } 293 } 294 }) 295 296 .on('moveend', function(e) { 297 wrap.removeClass('notransition'); 298 299 slides.css("left", ''); 300 301 if (slides) { 302 slides.css("left", ''); 303 } 304 if (slides) { 305 slides.css("left", ''); 306 } 307 }); 308 309 310 })(jQuery); 311 312 } 313 } 314 315 316 jQuery(document).ready(function($){ 317 var adminUrl = ot.adminUrl; 318 var gallery_id = ot.gallery_id; 319 320 OT_gallery.a_click(adminUrl, gallery_id); 321 322 //image resize 323 jQuery(".ot-gallery-image").css("max-height", jQuery(window).height()+"px"); 324 }); 325 326 //image resize by resizing window 327 jQuery(window).resize(function() { 328 jQuery(".ot-gallery-image").css("max-height", jQuery(window).height()+"px"); 329 }); 330 331 //key navigation 332 jQuery(document).keydown(function(e){ 333 var adminUrl = ot.adminUrl; 334 if (e.keyCode == 39) {
335 OT_gallery.Loading(jQuery('.ot-slide-item .next'),adminUrl,false); 336 OT_gallery.NextImage(jQuery('.ot-slide-item .next')); 337 OT_gallery.Thumbs(jQuery('.ot-slide-item .next')); 338 //return false; 339 } 340 if (e.keyCode == 37) { 341 OT_gallery.Loading(jQuery('.ot-slide-item .prev'),adminUrl,false); 342 OT_gallery.PrevImage(jQuery('.ot-slide-item .prev')); 343 OT_gallery.Thumbs(jQuery('.ot-slide-item .prev')); 344 //return false; 345 } 346 }); 347 348
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.