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").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 if(parseInt(OT_gallery.total_img()) > OT_gallery.opened_image(clicked)) { 145 OT_gallery.main_image(clicked).attr("data-id", parseInt(OT_gallery.opened_image(clicked))+1); 146 OT_gallery.prev_button(clicked).attr("rel", parseInt(OT_gallery.prev_button(clicked).attr("rel"))+1); 147 } 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 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)) { 176 waiter.removeClass("loaded"); 177 waiter.addClass("loading"); 178 179 jQuery.ajax({ 180 url:adminUrl, 181 type:"POST", 182 data:"action=load_next_image&gallery_id="+ID+"&next_image="+next, 183 success:function(results) { 184 image.attr("src", results); 185 //image resize 186 image.css("max-height", jQuery(window).height()+"px"); 187 image.load(function(){ 188 setTimeout(function () { 189 waiter.removeClass("loading"); 190 waiter.addClass("loaded"); 191 }, 800); 192 193 194 }); 195 } 196 }); 197 198 } 199 }, 200 201 Thumbs : function (clicked) { 202 203 jQuery.each(OT_gallery.active_thumb(), function() { 204 jQuery(this).removeClass("active"); 205 if(jQuery(this).attr("data-nr") == OT_gallery.opened_image(clicked)) { 206 jQuery(this).addClass("active"); 207 } 208 209 }); 210 211 212 }, 213 214 215 216 // swipe navigation 217 swipe : function (xx) { 218 219 (function(jQuery, undefined) { 220 221 var adminUrl = ot.adminUrl; 222 var wrap = jQuery('.waiter'), 223 slides = wrap.find('.image-big-gallery'), 224 225 width = wrap.width(); 226 227 // Listen for swipe events on slides, and use a custom 'activate' 228 // or next slide, and to keep the index up-to-date. The class 229 230 slides 231 232 .on('swipeleft', function(e) {
233 OT_gallery.Loading(jQuery('.ot-slide-item .next'),adminUrl,true); 234 OT_gallery.NextImage(jQuery('.ot-slide-item .next')); 235 OT_gallery.Thumbs(jQuery('.ot-slide-item .next')); 236 }) 237 238 .on('swiperight', function(e) { 239 OT_gallery.Loading(jQuery('.ot-slide-item .prev'),adminUrl,true); 240 OT_gallery.PrevImage(jQuery('.ot-slide-item .prev')); 241 OT_gallery.Thumbs(jQuery('.ot-slide-item .prev')); 242 }) 243 244 245 246 // The code below handles what happens before any swipe event is triggered. 247 // It makes the slides demo on this page work nicely, but really doesn't 248 // have much to do with demonstrating the swipe events themselves. For more 249 // on move events see: 250 // 251 // http://stephband.info/jquery.event.move 252 253 .on('movestart', function(e) { 254 // If the movestart heads off in a upwards or downwards 255 // direction, prevent it so that the browser scrolls normally. 256 if ((e.distX > e.distY && e.distX < -e.distY) || 257 (e.distX < e.distY && e.distX > -e.distY)) { 258 e.preventDefault(); 259 return; 260 } 261 262 // To allow the slide to keep step with the finger, 263 // temporarily disable transitions. 264 wrap.addClass('notransition'); 265 }) 266 267 .on('move', function(e) { 268 var left = xx * e.distX / width; 269 270 // Move slides with the finger 271 if (e.distX < 0) { 272 if (slides) { 273 slides.css("left", left + '%'); 274 slides.css("left", (left+0)+'%'); 275 } 276 else { 277 slides.css("left", left/4 + '%'); 278 } 279 } 280 if (e.distX > 0) { 281 if (slides) { 282 slides.css("left", left + '%'); 283 slides.css("left", (left-0)+'%'); 284 } 285 else { 286 slides.css("left", left/5 + '%'); 287 } 288 } 289 }) 290 291 .on('moveend', function(e) { 292 wrap.removeClass('notransition'); 293 294 slides.css("left", ''); 295 296 if (slides) { 297 slides.css("left", ''); 298 } 299 if (slides) { 300 slides.css("left", ''); 301 } 302 }); 303 304 305 })(jQuery); 306 307 } 308 } 309 310 311 jQuery(document).ready(function($){ 312 var adminUrl = ot.adminUrl; 313 var gallery_id = ot.gallery_id; 314 315 OT_gallery.a_click(adminUrl, gallery_id); 316 317 //image resize 318 jQuery(".ot-gallery-image").css("max-height", jQuery(window).height()+"px"); 319 }); 320 321 //image resize by resizing window 322 jQuery(window).resize(function() { 323 jQuery(".ot-gallery-image").css("max-height", jQuery(window).height()+"px"); 324 }); 325 326 //key navigation 327 jQuery(document).keydown(function(e){ 328 var adminUrl = ot.adminUrl; 329 if (e.keyCode == 39) {
330 OT_gallery.Loading(jQuery('.ot-slide-item .next'),adminUrl,false); 331 OT_gallery.NextImage(jQuery('.ot-slide-item .next')); 332 OT_gallery.Thumbs(jQuery('.ot-slide-item .next')); 333 return false; 334 } 335 if (e.keyCode == 37) { 336 OT_gallery.Loading(jQuery('.ot-slide-item .prev'),adminUrl,false); 337 OT_gallery.PrevImage(jQuery('.ot-slide-item .prev')); 338 OT_gallery.Thumbs(jQuery('.ot-slide-item .prev')); 339 return false; 340 } 341 }); 342 343 344
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.