1(function ($) { 2 Drupal.viewsSlideshow = Drupal.viewsSlideshow || {}; 3 4 /** 5 * Views Slideshow Controls 6 */ 7 Drupal.viewsSlideshowControls = Drupal.viewsSlideshowControls || {}; 8 9 /** 10 * Implement the play hook for controls. 11 */ 12 Drupal.viewsSlideshowControls.play = function (options) { 13 // Route the control call to the correct control type. 14 // Need to use try catch so we don't have to check to make sure every part 15 // of the object is defined. 16 try { 17 if (typeof Drupal.settings.viewsSlideshowControls[options.slideshowID].top.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowControls[options.slideshowID].top.type].play == 'function') { 18 Drupal[Drupal.settings.viewsSlideshowControls[options.slideshowID].top.type].play(options); 19 } 20 } 21 catch(err) { 22 // Don't need to do anything on error. 23 }; 24 25 try { 26 if (typeof Drupal.settings.viewsSlideshowControls[options.slideshowID].bottom.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowControls[options.slideshowID].bottom.type].play == 'function') { 27 Drupal[Drupal.settings.viewsSlideshowControls[options.slideshowID].bottom.type].play(options); 28 } 29 } 30 catch(err) { 31 // Don't need to do anything on error. 32 } 33 }; 34 35 /** 36 * Implement the pause hook for controls. 37 */ 38 Drupal.viewsSlideshowControls.pause = function (options) { 39 // Route the control call to the correct control type. 40 // Need to use try catch so we don't have to check to make sure every part 41 // of the object is defined. 42 try { 43 if (typeof Drupal.settings.viewsSlideshowControls[options.slideshowID].top.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowControls[options.slideshowID].top.type].pause == 'function') { 44 Drupal[Drupal.settings.viewsSlideshowControls[options.slideshowID].top.type].pause(options); 45 } 46 } 47 catch(err) { 48 // Don't need to do anything on error. 49 } 50 51 try { 52 if (typeof Drupal.settings.viewsSlideshowControls[options.slideshowID].bottom.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowControls[options.slideshowID].bottom.type].pause == 'function') { 53 Drupal[Drupal.settings.viewsSlideshowControls[options.slideshowID].bottom.type].pause(options); 54 } 55 } 56 catch(err) { 57 // Don't need to do anything on error. 58 } 59 }; 60 61 62 /** 63 * Views Slideshow Text Controls 64 */ 65 66 // Add views slieshow api calls for views slideshow text controls. 67 Drupal.behaviors.viewsSlideshowControlsText = function (context) { 68 // Process previous link 69 $('.views_slideshow_controls_text_previous:not(.views-slideshow-controls-text-previous-processed)', context).addClass('views-slideshow-controls-text-previous-processed').each(function() { 70 var uniqueID = $(this).attr('id').replace('views_slideshow_controls_text_previous_', ''); 71 $(this).click(function() { 72 Drupal.viewsSlideshow.action({ "action": 'previousSlide', "slideshowID": uniqueID }); 73 return false; 74 }); 75 }); 76 77 // Process next link 78 $('.views_slideshow_controls_text_next:not(.views-slideshow-controls-text-next-processed)', context).addClass('views-slideshow-controls-text-next-processed').each(function() { 79 var uniqueID = $(this).attr('id').replace('views_slideshow_controls_text_next_', ''); 80 $(this).click(function() { 81 Drupal.viewsSlideshow.action({ "action": 'nextSlide', "slideshowID": uniqueID }); 82 return false; 83 }); 84 }); 85 86 // Process pause link 87 $('.views_slideshow_controls_text_pause:not(.views-slideshow-controls-text-pause-processed)', context).addClass('views-slideshow-controls-text-pause-processed').each(function() { 88 var uniqueID = $(this).attr('id').replace('views_slideshow_controls_text_pause_', ''); 89 $(this).click(function() { 90 if (Drupal.settings.viewsSlideshow[uniqueID].paused) { 91 Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": uniqueID, "force": true }); 92 } 93 else { 94 Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": uniqueID, "force": true }); 95 } 96 return false;
97 }); 98 }); 99 }; 100 101 Drupal.viewsSlideshowControlsText = Drupal.viewsSlideshowControlsText || {}; 102 103 /** 104 * Implement the pause hook for text controls. 105 */ 106 Drupal.viewsSlideshowControlsText.pause = function (options) { 107 var pauseText = Drupal.theme.prototype['viewsSlideshowControlsPause'] ? Drupal.theme('viewsSlideshowControlsPause') : ''; 108 $('#views_slideshow_controls_text_pause_' + options.slideshowID + ' a').text(pauseText); 109 }; 110 111 /** 112 * Implement the play hook for text controls. 113 */ 114 Drupal.viewsSlideshowControlsText.play = function (options) { 115 var playText = Drupal.theme.prototype['viewsSlideshowControlsPlay'] ? Drupal.theme('viewsSlideshowControlsPlay') : ''; 116 $('#views_slideshow_controls_text_pause_' + options.slideshowID + ' a').text(playText); 117 }; 118 119 // Theme the resume control. 120 Drupal.theme.prototype.viewsSlideshowControlsPause = function () { 121 return Drupal.t('Resume'); 122 }; 123 124 // Theme the pause control. 125 Drupal.theme.prototype.viewsSlideshowControlsPlay = function () { 126 return Drupal.t('Pause'); 127 }; 128 129 /** 130 * Views Slideshow Pager 131 */ 132 Drupal.viewsSlideshowPager = Drupal.viewsSlideshowPager || {}; 133 134 /** 135 * Implement the transitionBegin hook for pagers. 136 */ 137 Drupal.viewsSlideshowPager.transitionBegin = function (options) { 138 // Route the pager call to the correct pager type. 139 // Need to use try catch so we don't have to check to make sure every part 140 // of the object is defined. 141 try { 142 if (typeof Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].transitionBegin == 'function') { 143 Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].transitionBegin(options); 144 } 145 } 146 catch(err) { 147 // Don't need to do anything on error. 148 } 149 150 try { 151 if (typeof Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type].transitionBegin == 'function') { 152 Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type].transitionBegin(options); 153 } 154 } 155 catch(err) { 156 // Don't need to do anything on error. 157 } 158 }; 159 160 /** 161 * Implement the goToSlide hook for pagers. 162 */ 163 Drupal.viewsSlideshowPager.goToSlide = function (options) { 164 // Route the pager call to the correct pager type. 165 // Need to use try catch so we don't have to check to make sure every part 166 // of the object is defined. 167 try { 168 if (typeof Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].goToSlide == 'function') { 169 Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].goToSlide(options); 170 } 171 } 172 catch(err) { 173 // Don't need to do anything on error. 174 } 175 176 try { 177 if (typeof Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type].goToSlide == 'function') { 178 Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type].goToSlide(options); 179 } 180 } 181 catch(err) { 182 // Don't need to do anything on error. 183 } 184 }; 185 186 /** 187 * Implement the previousSlide hook for pagers. 188 */ 189 Drupal.viewsSlideshowPager.previousSlide = function (options) { 190 // Route the pager call to the correct pager type. 191 // Need to use try catch so we don't have to check to make sure every part 192 // of the object is defined. 193 try { 194 if (typeof Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].previousSlide == 'function') { 195 Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].previousSlide(options); 196 } 197 } 198 catch(err) { 199 // Don't need to do anything on error. 200 } 201 202 try { 203 if (typeof Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type].previousSlide == 'function') { 204 Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type].previousSlide(options); 205 } 206 } 207 catch(err) { 208 // Don't need to do anything on error. 209 } 210 }; 211 212 /** 213 * Implement the nextSlide hook for pagers. 214 */ 215 Drupal.viewsSlideshowPager.nextSlide = function (options) { 216 // Route the pager call to the correct pager type. 217 // Need to use try catch so we don't have to check to make sure every part 218 // of the object is defined. 219 try { 220 if (typeof Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].nextSlide == 'function') { 221 Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].nextSlide(options); 222 } 223 } 224 catch(err) { 225 // Don't need to do anything on error. 226 } 227 228 try { 229 if (typeof Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type].nextSlide == 'function') { 230 Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type].nextSlide(options); 231 } 232 } 233 catch(err) { 234 // Don't need to do anything on error. 235 } 236 }; 237 238 239 /** 240 * Views Slideshow Pager Fields 241 */ 242 243 // Add views slieshow api calls for views slideshow pager fields. 244 Drupal.behaviors.viewsSlideshowPagerFields = function (context) { 245 // Process pause on hover.
246 $('.views_slideshow_pager_field:not(.views-slideshow-pager-field-processed)', context).addClass('views-slideshow-pager-field-processed').each(function() { 247 // Parse out the location and unique id from the full id. 248 var pagerInfo = $(this).attr('id').split('_'); 249 var location = pagerInfo[2]; 250 pagerInfo.splice(0, 3); 251 var uniqueID = pagerInfo.join('_'); 252 253 // Add the activate and pause on pager hover event to each pager item. 254 if (Drupal.settings.viewsSlideshowPagerFields[uniqueID][location].activatePauseOnHover) { 255 $(this).children().each(function(index, pagerItem) { 256 var mouseIn = function() { 257 Drupal.viewsSlideshow.action({ "action": 'goToSlide', "slideshowID": uniqueID, "slideNum": index }); 258 Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": uniqueID }); 259 } 260 261 var mouseOut = function() { 262 Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": uniqueID }); 263 } 264 265 if (jQuery.fn.hoverIntent) { 266 $(pagerItem).hoverIntent(mouseIn, mouseOut); 267 } 268 else { 269 $(pagerItem).hover(mouseIn, mouseOut); 270 } 271 }); 272 } 273 else { 274 $(this).children().each(function(index, pagerItem) { 275 $(pagerItem).click(function() { 276 Drupal.viewsSlideshow.action({ "action": 'goToSlide', "slideshowID": uniqueID, "slideNum": index }); 277 }); 278 }); 279 } 280 }); 281 }; 282 283 Drupal.viewsSlideshowPagerFields = Drupal.viewsSlideshowPagerFields || {}; 284 285 /** 286 * Implement the transitionBegin hook for pager fields pager. 287 */ 288 Drupal.viewsSlideshowPagerFields.transitionBegin = function (options) { 289 for(pagerLocation in Drupal.settings.viewsSlideshowPager[options.slideshowID]) { 290 // Remove active class from pagers 291 $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"]').removeClass('active'); 292 293 // Add active class to active pager. 294 $('#views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '_' + options.slideNum).addClass('active'); 295 } 296 }; 297 298 /** 299 * Implement the goToSlide hook for pager fields pager. 300 */ 301 Drupal.viewsSlideshowPagerFields.goToSlide = function (options) { 302 for(pagerLocation in Drupal.settings.viewsSlideshowPager[options.slideshowID]) { 303 // Remove active class from pagers 304 $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"]').removeClass('active'); 305 306 // Add active class to active pager. 307 $('#views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '_' + options.slideNum).addClass('active'); 308 } 309 }; 310 311 /** 312 * Implement the previousSlide hook for pager fields pager. 313 */ 314 Drupal.viewsSlideshowPagerFields.previousSlide = function (options) { 315 for(pagerLocation in Drupal.settings.viewsSlideshowPager[options.slideshowID]) { 316 // Get the current active pager. 317 var pagerNum = $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"].active').attr('id').replace('views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '_', ''); 318 319 // If we are on the first pager then activate the last pager. 320 // Otherwise activate the previous pager. 321 if (pagerNum == 0) { 322 pagerNum = $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"]').length() - 1; 323 } 324 else { 325 pagerNum--; 326 } 327 328 // Remove active class from pagers 329 $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"]').removeClass('active'); 330 331 // Add active class to active pager. 332 $('#views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '_' + pagerNum).addClass('active'); 333 } 334 }; 335 336 /** 337 * Implement the nextSlide hook for pager fields pager. 338 */ 339 Drupal.viewsSlideshowPagerFields.nextSlide = function (options) { 340 for(pagerLocation in Drupal.settings.viewsSlideshowPager[options.slideshowID]) { 341 // Get the current active pager. 342 var pagerNum = $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"].active').attr('id').replace('views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '_', ''); 343 var totalPagers = $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"]').length(); 344 345 // If we are on the last pager then activate the first pager. 346 // Otherwise activate the next pager. 347 pagerNum++; 348 if (pagerNum == totalPagers) { 349 pagerNum = 0; 350 } 351 352 // Remove active class from pagers 353 $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"]').removeClass('active'); 354 355 // Add active class to active pager. 356 $('#views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '_' + slideNum).addClass('active'); 357 } 358 }; 359 360 361 /** 362 * Views Slideshow Slide Counter 363 */ 364 365 Drupal.viewsSlideshowSlideCounter = Drupal.viewsSlideshowSlideCounter || {}; 366 367 /** 368 * Implement the transitionBegin for the slide counter. 369 */ 370 Drupal.viewsSlideshowSlideCounter.transitionBegin = function (options) { 371 $('#views_slideshow_slide_counter_' + options.slideshowID + ' .num').text(options.slideNum + 1); 372 }; 373 374 /** 375 * This is used as a router to process actions for the slideshow. 376 */ 377 Drupal.viewsSlideshow.action = function (options) { 378 // Set default values for our return status. 379 var status = { 380 'value': true, 381 'text': '' 382 } 383 384 // If an action isn't specified return false. 385 if (typeof options.action == 'undefined' || options.action == '') { 386 status.value = false;
387 status.text = Drupal.t('There was no action specified.'); 388 return error; 389 } 390 391 // If we are using pause or play switch paused state accordingly. 392 if (options.action == 'pause') { 393 Drupal.settings.viewsSlideshow[options.slideshowID].paused = 1; 394 // If the calling method is forcing a pause then mark it as such. 395 if (options.force) { 396 Drupal.settings.viewsSlideshow[options.slideshowID].pausedForce = 1; 397 } 398 } 399 else if (options.action == 'play') { 400 // If the slideshow isn't forced pause or we are forcing a play then play 401 // the slideshow. 402 // Otherwise return telling the calling method that it was forced paused. 403 if (!Drupal.settings.viewsSlideshow[options.slideshowID].pausedForce || options.force) { 404 Drupal.settings.viewsSlideshow[options.slideshowID].paused = 0; 405 Drupal.settings.viewsSlideshow[options.slideshowID].pausedForce = 0; 406 } 407 else { 408 status.value = false; 409 status.text += ' ' + Drupal.t('This slideshow is forced paused.'); 410 return status; 411 } 412 } 413 414 // We use a switch statement here mainly just to limit the type of actions 415 // that are available. 416 switch (options.action) { 417 case "goToSlide": 418 case "transitionBegin": 419 case "transitionEnd": 420 // The three methods above require a slide number. Checking if it is 421 // defined and it is a number that is an integer. 422 if (typeof options.slideNum == 'undefined' || typeof options.slideNum !== 'number' || parseInt(options.slideNum) != (options.slideNum - 0)) { 423 status.value = false; 424 status.text = Drupal.t('An invalid integer was specified for slideNum.'); 425 } 426 case "pause": 427 case "play": 428 case "nextSlide": 429 case "previousSlide": 430 // Grab our list of methods. 431 var methods = Drupal.settings.viewsSlideshow[options.slideshowID]['methods']; 432 433 // if the calling method specified methods that shouldn't be called then 434 // exclude calling them. 435 var excludeMethodsObj = {}; 436 if (typeof options.excludeMethods !== 'undefined') { 437 // We need to turn the excludeMethods array into an object so we can use the in 438 // function. 439 for (var i=0; i < excludeMethods.length; i++) { 440 excludeMethodsObj[excludeMethods[i]] = ''; 441 } 442 } 443 444 // Call every registered method and don't call excluded ones. 445 for (i = 0; i < methods[options.action].length; i++) { 446 if (Drupal[methods[options.action][i]] != undefined && typeof Drupal[methods[options.action][i]][options.action] == 'function' && !(methods[options.action][i] in excludeMethodsObj)) { 447 Drupal[methods[options.action][i]][options.action](options); 448 } 449 } 450 break; 451 452 // If it gets here it's because it's an invalid action. 453 default: 454 status.value = false; 455 status.text = Drupal.t('An invalid action "!action" was specified.', { "!action": options.action }); 456 } 457 return status; 458 }; 459})(jQuery);
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.