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