/** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ (function () { var settingsElement = document.querySelector('head > script[type="application/json"][data-drupal-selector="drupal-settings-json"], body > script[type="application/json"][data-drupal-selector="drupal-settings-json"]'); window.drupalSettings = {}; if (settingsElement !== null) { window.drupalSettings = JSON.parse(settingsElement.textContent); } })();; /** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ window.Drupal = { behaviors: {}, locale: {} }; (function (Drupal, drupalSettings, drupalTranslations, console, Proxy, Reflect) { Drupal.throwError = function (error) { setTimeout(function () { throw error; }, 0); }; Drupal.attachBehaviors = function (context, settings) { context = context || document; settings = settings || drupalSettings; var behaviors = Drupal.behaviors; Object.keys(behaviors || {}).forEach(function (i) { if (typeof behaviors[i].attach === 'function') { try { behaviors[i].attach(context, settings); } catch (e) { Drupal.throwError(e); } } }); }; Drupal.detachBehaviors = function (context, settings, trigger) { context = context || document; settings = settings || drupalSettings; trigger = trigger || 'unload'; var behaviors = Drupal.behaviors; Object.keys(behaviors || {}).forEach(function (i) { if (typeof behaviors[i].detach === 'function') { try { behaviors[i].detach(context, settings, trigger); } catch (e) { Drupal.throwError(e); } } }); }; Drupal.checkPlain = function (str) { str = str.toString().replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); return str; }; Drupal.formatString = function (str, args) { var processedArgs = {}; Object.keys(args || {}).forEach(function (key) { switch (key.charAt(0)) { case '@': processedArgs[key] = Drupal.checkPlain(args[key]); break; case '!': processedArgs[key] = args[key]; break; default: processedArgs[key] = Drupal.theme('placeholder', args[key]); break; } }); return Drupal.stringReplace(str, processedArgs, null); }; Drupal.stringReplace = function (str, args, keys) { if (str.length === 0) { return str; } if (!Array.isArray(keys)) { keys = Object.keys(args || {}); keys.sort(function (a, b) { return a.length - b.length; }); } if (keys.length === 0) { return str; } var key = keys.pop(); var fragments = str.split(key); if (keys.length) { for (var i = 0; i < fragments.length; i++) { fragments[i] = Drupal.stringReplace(fragments[i], args, keys.slice(0)); } } return fragments.join(args[key]); }; Drupal.t = function (str, args, options) { options = options || {}; options.context = options.context || ''; if (typeof drupalTranslations !== 'undefined' && drupalTranslations.strings && drupalTranslations.strings[options.context] && drupalTranslations.strings[options.context][str]) { str = drupalTranslations.strings[options.context][str]; } if (args) { str = Drupal.formatString(str, args); } return str; }; Drupal.url = function (path) { return drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix + path; }; Drupal.url.toAbsolute = function (url) { var urlParsingNode = document.createElement('a'); try { url = decodeURIComponent(url); } catch (e) {} urlParsingNode.setAttribute('href', url); return urlParsingNode.cloneNode(false).href; }; Drupal.url.isLocal = function (url) { var absoluteUrl = Drupal.url.toAbsolute(url); var protocol = window.location.protocol; if (protocol === 'http:' && absoluteUrl.indexOf('https:') === 0) { protocol = 'https:'; } var baseUrl = protocol + '//' + window.location.host + drupalSettings.path.baseUrl.slice(0, -1); try { absoluteUrl = decodeURIComponent(absoluteUrl); } catch (e) {} try { baseUrl = decodeURIComponent(baseUrl); } catch (e) {} return absoluteUrl === baseUrl || absoluteUrl.indexOf(baseUrl + '/') === 0; }; Drupal.formatPlural = function (count, singular, plural, args, options) { args = args || {}; args['@count'] = count; var pluralDelimiter = drupalSettings.pluralDelimiter; var translations = Drupal.t(singular + pluralDelimiter + plural, args, options).split(pluralDelimiter); var index = 0; if (typeof drupalTranslations !== 'undefined' && drupalTranslations.pluralFormula) { index = count in drupalTranslations.pluralFormula ? drupalTranslations.pluralFormula[count] : drupalTranslations.pluralFormula.default; } else if (args['@count'] !== 1) { index = 1; } return translations[index]; }; Drupal.encodePath = function (item) { return window.encodeURIComponent(item).replace(/%2F/g, '/'); }; Drupal.deprecationError = function (_ref) { var message = _ref.message; if (drupalSettings.suppressDeprecationErrors === false && typeof console !== 'undefined' && console.warn) { console.warn('[Deprecation] ' + message); } }; Drupal.deprecatedProperty = function (_ref2) { var target = _ref2.target, deprecatedProperty = _ref2.deprecatedProperty, message = _ref2.message; if (!Proxy || !Reflect) { return target; } return new Proxy(target, { get: function get(target, key) { for (var _len = arguments.length, rest = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { rest[_key - 2] = arguments[_key]; } if (key === deprecatedProperty) { Drupal.deprecationError({ message: message }); } return Reflect.get.apply(Reflect, [target, key].concat(rest)); } }); }; Drupal.theme = function (func) { if (func in Drupal.theme) { var _Drupal$theme; for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } return (_Drupal$theme = Drupal.theme)[func].apply(_Drupal$theme, args); } }; Drupal.theme.placeholder = function (str) { return '' + Drupal.checkPlain(str) + ''; }; })(Drupal, window.drupalSettings, window.drupalTranslations, window.console, window.Proxy, window.Reflect);; /** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ if (window.jQuery) { jQuery.noConflict(); } document.documentElement.className += ' js'; (function (Drupal, drupalSettings) { var domReady = function domReady(callback) { if (document.readyState !== 'loading') { callback(); } else { var listener = function listener() { callback(); document.removeEventListener('DOMContentLoaded', listener); }; document.addEventListener('DOMContentLoaded', listener); } }; domReady(function () { Drupal.attachBehaviors(document, drupalSettings); }); })(Drupal, window.drupalSettings);; /** * @file * Drupal Bootstrap object. */ /** * All Drupal Bootstrap JavaScript APIs are contained in this namespace. * * @namespace */ (function ($, Drupal) { 'use strict'; Drupal.bootstrap = { settings: drupalSettings.bootstrap || {} }; /** * Wraps Drupal.checkPlain() to ensure value passed isn't empty. * * Encodes special characters in a plain-text string for display as HTML. * * @param {string} str * The string to be encoded. * * @return {string} * The encoded string. * * @ingroup sanitization */ Drupal.bootstrap.checkPlain = function (str) { return str && Drupal.checkPlain(str) || ''; }; /** * Extends a Bootstrap plugin constructor. * * @param {string} id * A Bootstrap plugin identifier located in $.fn. * @param {function} [callback] * A callback to extend the plugin constructor. * * @return {function|boolean} * The Bootstrap plugin or FALSE if the plugin does not exist. */ Drupal.bootstrap.extendPlugin = function (id, callback) { // Immediately return if the plugin does not exist. if (!$.fn[id] || !$.fn[id].Constructor) return false; // Extend the plugin if a callback was provided. if ($.isFunction(callback)) { var ret = callback.apply($.fn[id].Constructor, [this.settings]); if ($.isPlainObject(ret)) { $.extend(true, $.fn[id].Constructor, ret); } } // Add a jQuery UI like option getter/setter method. if ($.fn[id].Constructor.prototype.option === void(0)) { $.fn[id].Constructor.prototype.option = this.option; } return $.fn[id].Constructor; }; /** * Replaces a Bootstrap jQuery plugin definition. * * @param {string} id * A Bootstrap plugin identifier located in $.fn. * @param {function} [callback] * A callback to replace the jQuery plugin definition. The callback must * return a function that is used to construct a jQuery plugin. * * @return {function|boolean} * The Bootstrap jQuery plugin definition or FALSE if the plugin does not * exist. */ Drupal.bootstrap.replacePlugin = function (id, callback) { // Immediately return if plugin does not exist or not a valid callback. if (!$.fn[id] || !$.fn[id].Constructor || !$.isFunction(callback)) return false; var constructor = $.fn[id].Constructor; var plugin = callback.apply(constructor); if ($.isFunction(plugin)) { plugin.Constructor = constructor; var old = $.fn[id]; plugin.noConflict = function () { $.fn[id] = old; return this; }; $.fn[id] = plugin; } }; /** * Provide jQuery UI like ability to get/set options for Bootstrap plugins. * * @param {string|object} key * A string value of the option to set, can be dot like to a nested key. * An object of key/value pairs. * @param {*} [value] * (optional) A value to set for key. * * @returns {*} * - Returns nothing if key is an object or both key and value parameters * were provided to set an option. * - Returns the a value for a specific setting if key was provided. * - Returns an object of key/value pairs of all the options if no key or * value parameter was provided. * * @see https://github.com/jquery/jquery-ui/blob/master/ui/widget.js * * @todo This isn't fully working since Bootstrap plugins don't allow * methods to return values. */ Drupal.bootstrap.option = function (key, value) { var options = key; var parts, curOption, i; // Don't return a reference to the internal hash. if (arguments.length === 0) { return $.extend({}, this.options); } // Handle a specific option. if (typeof key === "string") { // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } options = {}; parts = key.split("."); key = parts.shift(); if (parts.length) { curOption = options[key] = $.extend({}, this.options[key]); for (i = 0; i < parts.length - 1; i++) { curOption[parts[i]] = curOption[parts[i]] || {}; curOption = curOption[parts[i]]; } key = parts.pop(); if (arguments.length === 1) { return curOption[key] === undefined ? null : curOption[key]; } curOption[key] = value; } else { if (arguments.length === 1) { return this.options[key] === undefined ? null : this.options[key]; } options[key] = value; } } // Set the new option(s). for (key in options) { if (!options.hasOwnProperty(key)) continue; this.options[key] = options[key]; } return this; }; })(window.jQuery, window.Drupal, window.drupalSettings); ; (function ($, _) { /** * Class to help modify attributes. * * @param {object} object * An object to initialize attributes with. * * @constructor */ var Attributes = function (object) { this.data = object && _.isObject(object) && _.clone(object) || {}; }; /** * Renders the attributes object as a string to inject into an HTML element. * * @returns {string} */ Attributes.prototype.toString = function () { var output = ''; var name, value; var checkPlain = function (str) { return str && str.toString().replace(/&/g, '&').replace(/"/g, '"').replace(//g, '>') || ''; }; for (name in this.data) { if (!this.data.hasOwnProperty(name)) continue; value = this.data[name]; if (_.isFunction(value)) value = value(); if (_.isObject(value)) value = _.values(value); if (_.isArray(value)) value = value.join(' '); output += ' ' + checkPlain(name) + '="' + checkPlain(value) + '"'; } return output; }; /** * Add class(es) to the array. * * @param {string|Array} value * An individual class or an array of classes to add. * * @return {Attributes} * * @chainable */ Attributes.prototype.addClass = function (value) { var classes = this.getClasses(); value = [].concat(classes, value); this.set('class', _.uniq(value)); return this; }; /** * Returns whether the requested attribute exists. * * @param {string} name * An attribute name to check. * * @return {boolean} * TRUE or FALSE */ Attributes.prototype.exists = function (name) { return this.data[name] !== void(0) && this.data[name] !== null; }; /** * Retrieve a specific attribute from the array. * * @param {string} name * The specific attribute to retrieve. * @param {*} defaultValue * (optional) The default value to set if the attribute does not exist. * * @return {*} * A specific attribute value, passed by reference. */ Attributes.prototype.get = function (name, defaultValue) { if (!this.exists(name)) this.data[name] = defaultValue; return this.data[name]; }; /** * Retrieves a cloned copy of the internal attributes data object. * * @returns {Object} */ Attributes.prototype.getData = function () { return _.clone(this.data); }; /** * Retrieves classes from the array. * * @return {Array} * The classes array. */ Attributes.prototype.getClasses = function () { var classes = [].concat(this.get('class', [])); return _.uniq(classes); }; /** * Indicates whether a class is present in the array. * * @param {string|Array} name * The class(es) to search for. * * @return {boolean} * TRUE or FALSE */ Attributes.prototype.hasClass = function (name) { name = [].concat(name); var classes = this.getClasses(); var found = false; _.each(name, function (value) { if (_.indexOf(classes, value) !== -1) found = true; }); return found; }; /** * Merges multiple values into the array. * * @param {object} values * An associative key/value array. * @param {boolean} [recursive] * Flag determining whether or not to recursively merge key/value pairs. * * @return {Attributes} * * @chainable */ Attributes.prototype.merge = function (values, recursive) { values = values instanceof Attributes ? values.getData() : values; if (recursive === void(0) || recursive) { this.data = $.extend(true, {}, this.data, values); } else { $.extend(this.data, values); } return this; }; /** * Removes an attribute from the array. * * @param {string} name * The name of the attribute to remove. * * @return {Attributes} * * @chainable */ Attributes.prototype.remove = function (name) { if (this.exists(name)) delete this.data[name]; return this; }; /** * Removes a class from the attributes array. * * @param {string|Array} value * An individual class or an array of classes to remove. * * @return {Attributes} * * @chainable */ Attributes.prototype.removeClass = function (value) { this.set('class', _.without(this.getClasses(), [].concat(value))); return this; }; /** * Replaces a class in the attributes array. * * @param {string} oldValue * The old class to remove. * @param {string} newValue * The new class. It will not be added if the old class does not exist. * * @return {Attributes} * * @chainable */ Attributes.prototype.replaceClass = function (oldValue, newValue) { var classes = this.getClasses(); var i = _.indexOf(oldValue, classes); if (i >= 0) { classes[i] = newValue; this.set('class', classes); } return this; }; /** * Sets an attribute on the array. * * @param {string} name * The name of the attribute to set. * @param {*} value * The value of the attribute to set. * * @return {Attributes} * * @chainable */ Attributes.prototype.set = function (name, value) { this.data[name] = value; return this; }; /** * Creates an Attributes instance. * * @param {object|Attributes} object * An object to initialize attributes with. * * @returns {Attributes} * * @global * * @constructor */ window.Attributes = function (object) { return object instanceof Attributes ? object : new Attributes(object); }; })(window.jQuery, window._); ; /** * @file * Theme hooks for the Drupal Bootstrap base theme. */ (function ($, Drupal, Bootstrap) { /** * Fallback for theming an icon if the Icon API module is not installed. */ if (!Drupal.icon) Drupal.icon = { bundles: {} }; if (!Drupal.theme.icon || Drupal.theme.prototype.icon) { $.extend(Drupal.theme, /** @lends Drupal.theme */ { /** * Renders an icon. * * @param {string} bundle * The bundle which the icon belongs to. * @param {string} icon * The name of the icon to render. * @param {object|Attributes} [attributes] * An object of attributes to also apply to the icon. * * @returns {string} */ icon: function (bundle, icon, attributes) { if (!Drupal.icon.bundles[bundle]) return ''; attributes = Attributes(attributes).addClass('icon').set('aria-hidden', 'true'); icon = Drupal.icon.bundles[bundle](icon, attributes); return ''; } }); } /** * Callback for modifying an icon in the "bootstrap" icon bundle. * * @param {string} icon * The icon being rendered. * @param {Attributes} attributes * Attributes object for the icon. */ Drupal.icon.bundles.bootstrap = function (icon, attributes) { attributes.addClass(['glyphicon', 'glyphicon-' + icon]); }; /** * Add necessary theming hooks. */ $.extend(Drupal.theme, /** @lends Drupal.theme */ { /** * Renders a Bootstrap AJAX glyphicon throbber. * * @returns {string} */ ajaxThrobber: function () { return Drupal.theme.bootstrapIcon('refresh', {'class': ['ajax-throbber', 'glyphicon-spin'] }); }, /** * Renders a button element. * * @param {object|Attributes} attributes * An object of attributes to apply to the button. If it contains one of: * - value: The label of the button. * - context: The context type of Bootstrap button, can be one of: * - default * - primary * - success * - info * - warning * - danger * - link * * @returns {string} */ button: function (attributes) { attributes = Attributes(attributes).addClass('btn'); var context = attributes.get('context', 'default'); var label = attributes.get('value', ''); attributes.remove('context').remove('value'); if (!attributes.hasClass(['btn-default', 'btn-primary', 'btn-success', 'btn-info', 'btn-warning', 'btn-danger', 'btn-link'])) { attributes.addClass('btn-' + Bootstrap.checkPlain(context)); } return '' + label + ''; }, /** * Alias for "button" theme hook. * * @param {object|Attributes} attributes * An object of attributes to apply to the button. * * @see Drupal.theme.button() * * @returns {string} */ btn: function (attributes) { return Drupal.theme('button', attributes); }, /** * Renders a button block element. * * @param {object|Attributes} attributes * An object of attributes to apply to the button. * * @see Drupal.theme.button() * * @returns {string} */ 'btn-block': function (attributes) { return Drupal.theme('button', Attributes(attributes).addClass('btn-block')); }, /** * Renders a large button element. * * @param {object|Attributes} attributes * An object of attributes to apply to the button. * * @see Drupal.theme.button() * * @returns {string} */ 'btn-lg': function (attributes) { return Drupal.theme('button', Attributes(attributes).addClass('btn-lg')); }, /** * Renders a small button element. * * @param {object|Attributes} attributes * An object of attributes to apply to the button. * * @see Drupal.theme.button() * * @returns {string} */ 'btn-sm': function (attributes) { return Drupal.theme('button', Attributes(attributes).addClass('btn-sm')); }, /** * Renders an extra small button element. * * @param {object|Attributes} attributes * An object of attributes to apply to the button. * * @see Drupal.theme.button() * * @returns {string} */ 'btn-xs': function (attributes) { return Drupal.theme('button', Attributes(attributes).addClass('btn-xs')); }, /** * Renders a glyphicon. * * @param {string} name * The name of the glyphicon. * @param {object|Attributes} [attributes] * An object of attributes to apply to the icon. * * @returns {string} */ bootstrapIcon: function (name, attributes) { return Drupal.theme('icon', 'bootstrap', name, attributes); } }); })(window.jQuery, window.Drupal, window.Drupal.bootstrap); ; /** * @file * Bootstrap Popovers. */ var Drupal = Drupal || {}; (function ($, Drupal, Bootstrap) { "use strict"; /** * Extend the Bootstrap Popover plugin constructor class. */ Bootstrap.extendPlugin('popover', function (settings) { return { DEFAULTS: { animation: !!settings.popover_animation, html: !!settings.popover_html, placement: settings.popover_placement, selector: settings.popover_selector, trigger: settings.popover_trigger, triggerAutoclose: !!settings.popover_trigger_autoclose, title: settings.popover_title, content: settings.popover_content, delay: parseInt(settings.popover_delay, 10), container: settings.popover_container } }; }); /** * Bootstrap Popovers. * * @todo This should really be properly delegated if selector option is set. */ Drupal.behaviors.bootstrapPopovers = { attach: function (context) { // Popover autoclose. if ($.fn.popover.Constructor.DEFAULTS.triggerAutoclose) { var $currentPopover = null; $(document) .on('show.bs.popover', '[data-toggle=popover]', function () { var $trigger = $(this); var popover = $trigger.data('bs.popover'); // Only keep track of clicked triggers that we're manually handling. if (popover.options.originalTrigger === 'click') { if ($currentPopover && !$currentPopover.is($trigger)) { $currentPopover.popover('hide'); } $currentPopover = $trigger; } }) .on('click', function (e) { var $target = $(e.target); var popover = $target.is('[data-toggle=popover]') && $target.data('bs.popover'); if ($currentPopover && !$target.is('[data-toggle=popover]') && !$target.closest('.popover.in')[0]) { $currentPopover.popover('hide'); $currentPopover = null; } }) ; } var elements = $(context).find('[data-toggle=popover]').toArray(); for (var i = 0; i < elements.length; i++) { var $element = $(elements[i]); var options = $.extend({}, $.fn.popover.Constructor.DEFAULTS, $element.data()); // Store the original trigger. options.originalTrigger = options.trigger; // If the trigger is "click", then we'll handle it manually here. if (options.trigger === 'click') { options.trigger = 'manual'; } // Retrieve content from a target element. var $target = $(options.target || $element.is('a[href^="#"]') && $element.attr('href')).clone(); if (!options.content && $target[0]) { $target.removeClass('visually-hidden hidden').removeAttr('aria-hidden'); options.content = $target.wrap('
').parent()[options.html ? 'html' : 'text']() || ''; } // Initialize the popover. $element.popover(options); // Handle clicks manually. if (options.originalTrigger === 'click') { // To ensure the element is bound multiple times, remove any // previously set event handler before adding another one. $element .off('click.drupal.bootstrap.popover') .on('click.drupal.bootstrap.popover', function (e) { $(this).popover('toggle'); e.preventDefault(); e.stopPropagation(); }) ; } } }, detach: function (context) { // Destroy all popovers. $(context).find('[data-toggle="popover"]') .off('click.drupal.bootstrap.popover') .popover('destroy') ; } }; })(window.jQuery, window.Drupal, window.Drupal.bootstrap); ; /** * @file * Bootstrap Tooltips. */ var Drupal = Drupal || {}; (function ($, Drupal, Bootstrap) { "use strict"; /** * Extend the Bootstrap Tooltip plugin constructor class. */ Bootstrap.extendPlugin('tooltip', function (settings) { return { DEFAULTS: { animation: !!settings.tooltip_animation, html: !!settings.tooltip_html, placement: settings.tooltip_placement, selector: settings.tooltip_selector, trigger: settings.tooltip_trigger, delay: parseInt(settings.tooltip_delay, 10), container: settings.tooltip_container } }; }); /** * Bootstrap Tooltips. * * @todo This should really be properly delegated if selector option is set. */ Drupal.behaviors.bootstrapTooltips = { attach: function (context) { var elements = $(context).find('[data-toggle="tooltip"]').toArray(); for (var i = 0; i < elements.length; i++) { var $element = $(elements[i]); var options = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, $element.data()); $element.tooltip(options); } }, detach: function (context) { // Destroy all tooltips. $(context).find('[data-toggle="tooltip"]').tooltip('destroy'); } }; })(window.jQuery, window.Drupal, window.Drupal.bootstrap); ; ; ; /** * @file * A simple jQuery Cycle Div Slideshow Rotator. */ /** * This will set our initial behavior, by starting up each individual slideshow. */ (function ($, Drupal, drupalSettings) { Drupal.behaviors.viewsSlideshowCycle = { attach: function (context) { $('.views_slideshow_cycle_main:not(.viewsSlideshowCycle-processed)', context).addClass('viewsSlideshowCycle-processed').each(function() { var fullId = '#' + $(this).attr('id'); var settings = drupalSettings.viewsSlideshowCycle[fullId]; settings.targetId = '#' + $(fullId + " :first").attr('id'); settings.slideshowId = settings.targetId.replace('#views_slideshow_cycle_teaser_section_', ''); // Pager after function. var pager_after_fn = function(curr, next, opts) { // Need to do some special handling on first load. var slideNum = opts.currSlide; if (typeof settings.processedAfter == 'undefined' || !settings.processedAfter) { settings.processedAfter = 1; slideNum = (typeof settings.opts.startingSlide == 'undefined') ? 0 : settings.opts.startingSlide; } Drupal.viewsSlideshow.action({ "action": 'transitionEnd', "slideshowID": settings.slideshowId, "slideNum": slideNum }); } // Pager before function. var pager_before_fn = function(curr, next, opts) { var slideNum = opts.nextSlide; // Remember last slide. if (settings.remember_slide) { createCookie(settings.vss_id, slideNum, settings.remember_slide_days); } // Make variable height. if (!settings.fixed_height) { //get the height of the current slide var $ht = $(next).height(); //set the container's height to that of the current slide $(next).parent().animate({height: $ht}); } // Need to do some special handling on first load. if (typeof settings.processedBefore == 'undefined' || !settings.processedBefore) { settings.processedBefore = 1; slideNum = (typeof opts.startingSlide == 'undefined') ? 0 : opts.startingSlide; } Drupal.viewsSlideshow.action({ "action": 'transitionBegin', "slideshowID": settings.slideshowId, "slideNum": slideNum }); } settings.loaded = false; settings.opts = { speed:settings.speed, timeout:settings.timeout, delay:settings.delay, sync:settings.sync, random:settings.random, nowrap:settings.nowrap, after:pager_after_fn, before:pager_before_fn, cleartype:(settings.cleartype)? true : false, cleartypeNoBg:(settings.cleartypenobg)? true : false } // Set the starting slide if we are supposed to remember the slide if (settings.remember_slide) { var startSlide = readCookie(settings.vss_id); if (startSlide == null) { startSlide = 0; } settings.opts.startingSlide = parseInt(startSlide); } if (settings.effect == 'none') { settings.opts.speed = 1; } else { settings.opts.fx = settings.effect; } // Take starting item from fragment. var hash = location.hash; if (hash) { var hash = hash.replace('#', ''); var aHash = hash.split(';'); var aHashLen = aHash.length; // Loop through all the possible starting points. for (var i = 0; i < aHashLen; i++) { // Split the hash into two parts. One part is the slideshow id the // other is the slide number. var initialInfo = aHash[i].split(':'); // The id in the hash should match our slideshow. // The slide number chosen shouldn't be larger than the number of // slides we have. if (settings.slideshowId == initialInfo[0] && settings.num_divs > initialInfo[1]) { settings.opts.startingSlide = parseInt(initialInfo[1]); } } } // Pause on hover. if (settings.pause) { var mouseIn = function() { Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId }); } var mouseOut = function() { Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": settings.slideshowId }); } if (jQuery.fn.hoverIntent) { $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hoverIntent(mouseIn, mouseOut); } else { $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hover(mouseIn, mouseOut); } } // Pause on clicking of the slide. if (settings.pause_on_click) { $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).click(function() { Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId, "force": true }); }); } if (typeof JSON != 'undefined' && typeof settings.advanced_options != 'undefined') { var advancedOptions = JSON.parse(settings.advanced_options); for (var option in advancedOptions) { switch(option) { // Standard Options case "activePagerClass": case "allowPagerClickBubble": case "autostop": case "autostopCount": case "backwards": case "bounce": case "cleartype": case "cleartypeNoBg": case "containerResize": case "continuous": case "delay": case "easeIn": case "easeOut": case "easing": case "fastOnEvent": case "fit": case "fx": case "height": case "manualTrump": case "metaAttr": case "next": case "nowrap": case "pager": case "pagerEvent": case "pause": case "pauseOnPagerHover": case "prev": case "prevNextEvent": case "random": case "randomizeEffects": case "requeueOnImageNotLoaded": case "requeueTimeout": case "rev": case "slideExpr": case "slideResize": case "speed": case "speedIn": case "speedOut": case "startingSlide": case "sync": case "timeout": case "width": var optionValue = advancedOptions[option]; optionValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(optionValue); settings.opts[option] = optionValue; break; // These process options that look like {top:50, bottom:20} case "animIn": case "animOut": case "cssBefore": case "cssAfter": case "shuffle": var cssValue = advancedOptions[option]; cssValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(cssValue); settings.opts[option] = eval('(' + cssValue + ')'); break; // These options have their own functions. case "after": var afterValue = advancedOptions[option]; afterValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(afterValue); // transition callback (scope set to element that was shown): function(currSlideElement, nextSlideElement, options, forwardFlag) settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) { pager_after_fn(currSlideElement, nextSlideElement, options); eval(afterValue); } break; case "before": var beforeValue = advancedOptions[option]; beforeValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(beforeValue); // transition callback (scope set to element to be shown): function(currSlideElement, nextSlideElement, options, forwardFlag) settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) { pager_before_fn(currSlideElement, nextSlideElement, options); eval(beforeValue); } break; case "end": var endValue = advancedOptions[option]; endValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(endValue); // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options) settings.opts[option] = function(options) { eval(endValue); } break; case "fxFn": var fxFnValue = advancedOptions[option]; fxFnValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(fxFnValue); // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag) settings.opts[option] = function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag) { eval(fxFnValue); } break; case "onPagerEvent": var onPagerEventValue = advancedOptions[option]; onPagerEventValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(onPagerEventValue); settings.opts[option] = function(zeroBasedSlideIndex, slideElement) { eval(onPagerEventValue); } break; case "onPrevNextEvent": var onPrevNextEventValue = advancedOptions[option]; onPrevNextEventValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(onPrevNextEventValue); settings.opts[option] = function(isNext, zeroBasedSlideIndex, slideElement) { eval(onPrevNextEventValue); } break; case "pagerAnchorBuilder": var pagerAnchorBuilderValue = advancedOptions[option]; pagerAnchorBuilderValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(pagerAnchorBuilderValue); // callback fn for building anchor links: function(index, DOMelement) settings.opts[option] = function(index, DOMelement) { var returnVal = ''; eval(pagerAnchorBuilderValue); return returnVal; } break; case "pagerClick": var pagerClickValue = advancedOptions[option]; pagerClickValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(pagerClickValue); // callback fn for pager clicks: function(zeroBasedSlideIndex, slideElement) settings.opts[option] = function(zeroBasedSlideIndex, slideElement) { eval(pagerClickValue); } break; case "paused": var pausedValue = advancedOptions[option]; pausedValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(pausedValue); // undocumented callback when slideshow is paused: function(cont, opts, byHover) settings.opts[option] = function(cont, opts, byHover) { eval(pausedValue); } break; case "resumed": var resumedValue = advancedOptions[option]; resumedValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(resumedValue); // undocumented callback when slideshow is resumed: function(cont, opts, byHover) settings.opts[option] = function(cont, opts, byHover) { eval(resumedValue); } break; case "timeoutFn": var timeoutFnValue = advancedOptions[option]; timeoutFnValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(timeoutFnValue); settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) { eval(timeoutFnValue); } break; case "updateActivePagerLink": var updateActivePagerLinkValue = advancedOptions[option]; updateActivePagerLinkValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(updateActivePagerLinkValue); // callback fn invoked to update the active pager link (adds/removes activePagerClass style) settings.opts[option] = function(pager, currSlideIndex) { eval(updateActivePagerLinkValue); } break; } } } // If selected wait for the images to be loaded. // otherwise just load the slideshow. if (settings.wait_for_image_load) { // For IE/Chrome/Opera we if there are images then we need to make // sure the images are loaded before starting the slideshow. settings.totalImages = $(settings.targetId + ' img').length; if (settings.totalImages) { settings.loadedImages = 0; // Add a load event for each image. $(settings.targetId + ' img').each(function() { var $imageElement = $(this); $imageElement.bind('load', function () { Drupal.viewsSlideshowCycle.imageWait(fullId); }); // Removing the source and adding it again will fire the load event. var imgSrc = $imageElement.attr('src'); $imageElement.attr('src', ''); $imageElement.attr('src', imgSrc); }); // We need to set a timeout so that the slideshow doesn't wait // indefinitely for all images to load. setTimeout("Drupal.viewsSlideshowCycle.load('" + fullId + "')", settings.wait_for_image_load_timeout); } else { Drupal.viewsSlideshowCycle.load(fullId); } } else { Drupal.viewsSlideshowCycle.load(fullId); } }); } }; Drupal.viewsSlideshowCycle = Drupal.viewsSlideshowCycle || {}; // Cleanup the values of advanced options. Drupal.viewsSlideshowCycle.advancedOptionCleanup = function(value) { value = $.trim(value); value = value.replace(/\n/g, ''); if (!isNaN(parseInt(value))) { value = parseInt(value); } else if (value.toLowerCase() == 'true') { value = true; } else if (value.toLowerCase() == 'false') { value = false; } return value; } // This checks to see if all the images have been loaded. // If they have then it starts the slideshow. Drupal.viewsSlideshowCycle.imageWait = function(fullId) { if (++drupalSettings.viewsSlideshowCycle[fullId].loadedImages == drupalSettings.viewsSlideshowCycle[fullId].totalImages) { Drupal.viewsSlideshowCycle.load(fullId); } }; // Start the slideshow. Drupal.viewsSlideshowCycle.load = function (fullId) { var settings = drupalSettings.viewsSlideshowCycle[fullId]; // Make sure the slideshow isn't already loaded. if (!settings.loaded) { $(settings.targetId).cycle(settings.opts); settings.loaded = true; // Start Paused if (settings.start_paused) { Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId, "force": true }); } // Pause if hidden. if (settings.pause_when_hidden) { var checkPause = function(settings) { // If the slideshow is visible and it is paused then resume. // otherwise if the slideshow is not visible and it is not paused then // pause it. var visible = viewsSlideshowCycleIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible); if (visible) { Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": settings.slideshowId }); } else { Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId }); } } // Check when scrolled. $(window).scroll(function() { checkPause(settings); }); // Check when the window is resized. $(window).resize(function() { checkPause(settings); }); } } }; Drupal.viewsSlideshowCycle.pause = function (options) { //Eat TypeError, cycle doesn't handle pause well if options isn't defined. try{ if (options.pause_in_middle && $.fn.pause) { $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).pause(); } else { $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('pause'); } } catch(e){ if(!e instanceof TypeError){ throw e; } } }; Drupal.viewsSlideshowCycle.play = function (options) { drupalSettings.viewsSlideshowCycle['#views_slideshow_cycle_main_' + options.slideshowID].paused = false; if (options.pause_in_middle && $.fn.resume) { $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).resume(); } else { $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('resume'); } }; Drupal.viewsSlideshowCycle.previousSlide = function (options) { $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('prev'); }; Drupal.viewsSlideshowCycle.nextSlide = function (options) { $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('next'); }; Drupal.viewsSlideshowCycle.goToSlide = function (options) { $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle(options.slideNum); }; // Verify that the value is a number. function IsNumeric(sText) { var ValidChars = "0123456789"; var IsNumber=true; var Char; for (var i=0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1) { IsNumber = false; } } return IsNumber; } /** * Cookie Handling Functions */ function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else { var expires = ""; } document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) { return c.substring(nameEQ.length,c.length); } } return null; } function eraseCookie(name) { createCookie(name,"",-1); } /** * Checks to see if the slide is visible enough. * elem = element to check. * type = The way to calculate how much is visible. * amountVisible = amount that should be visible. Either in percent or px. If * it's not defined then all of the slide must be visible. * * Returns true or false */ function viewsSlideshowCycleIsVisible(elem, type, amountVisible) { // Get the top and bottom of the window; var docViewTop = $(window).scrollTop(); var docViewBottom = docViewTop + $(window).height(); var docViewLeft = $(window).scrollLeft(); var docViewRight = docViewLeft + $(window).width(); // Get the top, bottom, and height of the slide; var elemTop = $(elem).offset().top; var elemHeight = $(elem).height(); var elemBottom = elemTop + elemHeight; var elemLeft = $(elem).offset().left; var elemWidth = $(elem).width(); var elemRight = elemLeft + elemWidth; var elemArea = elemHeight * elemWidth; // Calculate what's hiding in the slide. var missingLeft = 0; var missingRight = 0; var missingTop = 0; var missingBottom = 0; // Find out how much of the slide is missing from the left. if (elemLeft < docViewLeft) { missingLeft = docViewLeft - elemLeft; } // Find out how much of the slide is missing from the right. if (elemRight > docViewRight) { missingRight = elemRight - docViewRight; } // Find out how much of the slide is missing from the top. if (elemTop < docViewTop) { missingTop = docViewTop - elemTop; } // Find out how much of the slide is missing from the bottom. if (elemBottom > docViewBottom) { missingBottom = elemBottom - docViewBottom; } // If there is no amountVisible defined then check to see if the whole slide // is visible. if (type == 'full') { return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) && (elemBottom <= docViewBottom) && (elemTop >= docViewTop) && (elemLeft >= docViewLeft) && (elemRight <= docViewRight) && (elemLeft <= docViewRight) && (elemRight >= docViewLeft)); } else if(type == 'vertical') { var verticalShowing = elemHeight - missingTop - missingBottom; // If user specified a percentage then find out if the current shown percent // is larger than the allowed percent. // Otherwise check to see if the amount of px shown is larger than the // allotted amount. if (amountVisible.indexOf('%')) { return (((verticalShowing/elemHeight)*100) >= parseInt(amountVisible)); } else { return (verticalShowing >= parseInt(amountVisible)); } } else if(type == 'horizontal') { var horizontalShowing = elemWidth - missingLeft - missingRight; // If user specified a percentage then find out if the current shown percent // is larger than the allowed percent. // Otherwise check to see if the amount of px shown is larger than the // allotted amount. if (amountVisible.indexOf('%')) { return (((horizontalShowing/elemWidth)*100) >= parseInt(amountVisible)); } else { return (horizontalShowing >= parseInt(amountVisible)); } } else if(type == 'area') { var areaShowing = (elemWidth - missingLeft - missingRight) * (elemHeight - missingTop - missingBottom); // If user specified a percentage then find out if the current shown percent // is larger than the allowed percent. // Otherwise check to see if the amount of px shown is larger than the // allotted amount. if (amountVisible.indexOf('%')) { return (((areaShowing/elemArea)*100) >= parseInt(amountVisible)); } else { return (areaShowing >= parseInt(amountVisible)); } } } })(jQuery, Drupal, drupalSettings); ; (function ($, Drupal, drupalSettings) { Drupal.viewsSlideshow = Drupal.viewsSlideshow || {}; /** * Views Slideshow Controls */ Drupal.viewsSlideshowControls = Drupal.viewsSlideshowControls || {}; /** * Implement the play hook for controls. */ Drupal.viewsSlideshowControls.play = function (options) { // Route the control call to the correct control type. // Need to use try catch so we don't have to check to make sure every part // of the object is defined. try { if (typeof drupalSettings.viewsSlideshowControls[options.slideshowID].top.type != "undefined" && typeof Drupal[drupalSettings.viewsSlideshowControls[options.slideshowID].top.type].play == 'function') { Drupal[drupalSettings.viewsSlideshowControls[options.slideshowID].top.type].play(options); } } catch(err) { // Don't need to do anything on error. } try { if (typeof drupalSettings.viewsSlideshowControls[options.slideshowID].bottom.type != "undefined" && typeof Drupal[drupalSettings.viewsSlideshowControls[options.slideshowID].bottom.type].play == 'function') { Drupal[drupalSettings.viewsSlideshowControls[options.slideshowID].bottom.type].play(options); } } catch(err) { // Don't need to do anything on error. } }; /** * Implement the pause hook for controls. */ Drupal.viewsSlideshowControls.pause = function (options) { // Route the control call to the correct control type. // Need to use try catch so we don't have to check to make sure every part // of the object is defined. try { if (typeof drupalSettings.viewsSlideshowControls[options.slideshowID].top.type != "undefined" && typeof Drupal[drupalSettings.viewsSlideshowControls[options.slideshowID].top.type].pause == 'function') { Drupal[drupalSettings.viewsSlideshowControls[options.slideshowID].top.type].pause(options); } } catch(err) { // Don't need to do anything on error. } try { if (typeof drupalSettings.viewsSlideshowControls[options.slideshowID].bottom.type != "undefined" && typeof Drupal[drupalSettings.viewsSlideshowControls[options.slideshowID].bottom.type].pause == 'function') { Drupal[drupalSettings.viewsSlideshowControls[options.slideshowID].bottom.type].pause(options); } } catch(err) { // Don't need to do anything on error. } }; /** * Views Slideshow Text Controls */ // Add views slieshow api calls for views slideshow text controls. Drupal.behaviors.viewsSlideshowControlsText = { attach: function (context) { // Process previous link $('.views_slideshow_controls_text_previous:not(.views-slideshow-controls-text-previous-processed)', context).addClass('views-slideshow-controls-text-previous-processed').each(function() { var uniqueID = $(this).attr('id').replace('views_slideshow_controls_text_previous_', ''); $(this).click(function() { Drupal.viewsSlideshow.action({ "action": 'previousSlide', "slideshowID": uniqueID }); return false; }); }); // Process next link $('.views_slideshow_controls_text_next:not(.views-slideshow-controls-text-next-processed)', context).addClass('views-slideshow-controls-text-next-processed').each(function() { var uniqueID = $(this).attr('id').replace('views_slideshow_controls_text_next_', ''); $(this).click(function() { Drupal.viewsSlideshow.action({ "action": 'nextSlide', "slideshowID": uniqueID }); return false; }); }); // Process pause link $('.views_slideshow_controls_text_pause:not(.views-slideshow-controls-text-pause-processed)', context).addClass('views-slideshow-controls-text-pause-processed').each(function() { var uniqueID = $(this).attr('id').replace('views_slideshow_controls_text_pause_', ''); $(this).click(function() { if (drupalSettings.viewsSlideshow[uniqueID].paused) { Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": uniqueID, "force": true }); } else { Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": uniqueID, "force": true }); } return false; }); }); } }; Drupal.viewsSlideshowControlsText = Drupal.viewsSlideshowControlsText || {}; /** * Implement the pause hook for text controls. */ Drupal.viewsSlideshowControlsText.pause = function (options) { var pauseText = Drupal.theme.prototype['viewsSlideshowControlsPause'] ? Drupal.theme('viewsSlideshowControlsPause') : ''; $('#views_slideshow_controls_text_pause_' + options.slideshowID + ' a').text(pauseText); $('#views_slideshow_controls_text_pause_' + options.slideshowID).removeClass('views-slideshow-controls-text-status-play'); $('#views_slideshow_controls_text_pause_' + options.slideshowID).addClass('views-slideshow-controls-text-status-pause'); }; /** * Implement the play hook for text controls. */ Drupal.viewsSlideshowControlsText.play = function (options) { var playText = Drupal.theme.prototype['viewsSlideshowControlsPlay'] ? Drupal.theme('viewsSlideshowControlsPlay') : ''; $('#views_slideshow_controls_text_pause_' + options.slideshowID + ' a').text(playText); $('#views_slideshow_controls_text_pause_' + options.slideshowID).removeClass('views-slideshow-controls-text-status-pause'); $('#views_slideshow_controls_text_pause_' + options.slideshowID).addClass('views-slideshow-controls-text-status-play'); }; // Theme the resume control. Drupal.theme.prototype.viewsSlideshowControlsPause = function () { return Drupal.t('Resume'); }; // Theme the pause control. Drupal.theme.prototype.viewsSlideshowControlsPlay = function () { return Drupal.t('Pause'); }; /** * Views Slideshow Pager */ Drupal.viewsSlideshowPager = Drupal.viewsSlideshowPager || {}; /** * Implement the transitionBegin hook for pagers. */ Drupal.viewsSlideshowPager.transitionBegin = function (options) { // Route the pager call to the correct pager type. // Need to use try catch so we don't have to check to make sure every part // of the object is defined. try { if (typeof drupalSettings.viewsSlideshowPager != "undefined" && typeof drupalSettings.viewsSlideshowPager[options.slideshowID].top.type != "undefined" && typeof Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].top.type].transitionBegin == 'function') { Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].top.type].transitionBegin(options); } } catch(err) { // Don't need to do anything on error. } try { if (typeof drupalSettings.viewsSlideshowPager != "undefined" && typeof drupalSettings.viewsSlideshowPager[options.slideshowID].bottom.type != "undefined" && typeof Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].bottom.type].transitionBegin == 'function') { Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].bottom.type].transitionBegin(options); } } catch(err) { // Don't need to do anything on error. } }; /** * Implement the goToSlide hook for pagers. */ Drupal.viewsSlideshowPager.goToSlide = function (options) { // Route the pager call to the correct pager type. // Need to use try catch so we don't have to check to make sure every part // of the object is defined. try { if (typeof drupalSettings.viewsSlideshowPager[options.slideshowID].top.type != "undefined" && typeof Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].top.type].goToSlide == 'function') { Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].top.type].goToSlide(options); } } catch(err) { // Don't need to do anything on error. } try { if (typeof drupalSettings.viewsSlideshowPager[options.slideshowID].bottom.type != "undefined" && typeof Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].bottom.type].goToSlide == 'function') { Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].bottom.type].goToSlide(options); } } catch(err) { // Don't need to do anything on error. } }; /** * Implement the previousSlide hook for pagers. */ Drupal.viewsSlideshowPager.previousSlide = function (options) { // Route the pager call to the correct pager type. // Need to use try catch so we don't have to check to make sure every part // of the object is defined. try { if (typeof drupalSettings.viewsSlideshowPager[options.slideshowID].top.type != "undefined" && typeof Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].top.type].previousSlide == 'function') { Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].top.type].previousSlide(options); } } catch(err) { // Don't need to do anything on error. } try { if (typeof drupalSettings.viewsSlideshowPager[options.slideshowID].bottom.type != "undefined" && typeof Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].bottom.type].previousSlide == 'function') { Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].bottom.type].previousSlide(options); } } catch(err) { // Don't need to do anything on error. } }; /** * Implement the nextSlide hook for pagers. */ Drupal.viewsSlideshowPager.nextSlide = function (options) { // Route the pager call to the correct pager type. // Need to use try catch so we don't have to check to make sure every part // of the object is defined. try { if (typeof drupalSettings.viewsSlideshowPager[options.slideshowID].top.type != "undefined" && typeof Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].top.type].nextSlide == 'function') { Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].top.type].nextSlide(options); } } catch(err) { // Don't need to do anything on error. } try { if (typeof drupalSettings.viewsSlideshowPager[options.slideshowID].bottom.type != "undefined" && typeof Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].bottom.type].nextSlide == 'function') { Drupal[drupalSettings.viewsSlideshowPager[options.slideshowID].bottom.type].nextSlide(options); } } catch(err) { // Don't need to do anything on error. } }; /** * Views Slideshow Pager Fields */ // Add views slieshow api calls for views slideshow pager fields. Drupal.behaviors.viewsSlideshowPagerFields = { attach: function (context) { // Process pause on hover. $('.views_slideshow_pager_field:not(.views-slideshow-pager-field-processed)', context).addClass('views-slideshow-pager-field-processed').each(function() { // Parse out the location and unique id from the full id. var pagerInfo = $(this).attr('id').split('_'); var location = pagerInfo[2]; pagerInfo.splice(0, 3); var uniqueID = pagerInfo.join('_'); // Add the activate and pause on pager hover event to each pager item. if (drupalSettings.viewsSlideshowPagerFields[uniqueID][location].activatePauseOnHover) { $(this).children().each(function(index, pagerItem) { var mouseIn = function() { Drupal.viewsSlideshow.action({ "action": 'goToSlide', "slideshowID": uniqueID, "slideNum": index }); Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": uniqueID }); }; var mouseOut = function() { Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": uniqueID }); }; if (jQuery.fn.hoverIntent) { $(pagerItem).hoverIntent(mouseIn, mouseOut); } else { $(pagerItem).hover(mouseIn, mouseOut); } }); } else { $(this).children().each(function(index, pagerItem) { $(pagerItem).click(function() { Drupal.viewsSlideshow.action({ "action": 'goToSlide', "slideshowID": uniqueID, "slideNum": index }); }); }); } }); } }; Drupal.viewsSlideshowPagerFields = Drupal.viewsSlideshowPagerFields || {}; /** * Implement the transitionBegin hook for pager fields pager. */ Drupal.viewsSlideshowPagerFields.transitionBegin = function (options) { for (pagerLocation in drupalSettings.viewsSlideshowPager[options.slideshowID]) { // Remove active class from pagers $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"]').removeClass('active'); // Add active class to active pager. $('#views_slideshow_pager_field_item_'+ pagerLocation + '_' + options.slideshowID + '_' + options.slideNum).addClass('active'); } }; /** * Implement the goToSlide hook for pager fields pager. */ Drupal.viewsSlideshowPagerFields.goToSlide = function (options) { for (pagerLocation in drupalSettings.viewsSlideshowPager[options.slideshowID]) { // Remove active class from pagers $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"]').removeClass('active'); // Add active class to active pager. $('#views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '_' + options.slideNum).addClass('active'); } }; /** * Implement the previousSlide hook for pager fields pager. */ Drupal.viewsSlideshowPagerFields.previousSlide = function (options) { for (pagerLocation in drupalSettings.viewsSlideshowPager[options.slideshowID]) { // Get the current active pager. var pagerNum = $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"].active').attr('id').replace('views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '_', ''); // If we are on the first pager then activate the last pager. // Otherwise activate the previous pager. if (pagerNum == 0) { pagerNum = $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"]').length() - 1; } else { pagerNum--; } // Remove active class from pagers $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"]').removeClass('active'); // Add active class to active pager. $('#views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '_' + pagerNum).addClass('active'); } }; /** * Implement the nextSlide hook for pager fields pager. */ Drupal.viewsSlideshowPagerFields.nextSlide = function (options) { for (pagerLocation in drupalSettings.viewsSlideshowPager[options.slideshowID]) { // Get the current active pager. var pagerNum = $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"].active').attr('id').replace('views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '_', ''); var totalPagers = $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"]').length(); // If we are on the last pager then activate the first pager. // Otherwise activate the next pager. pagerNum++; if (pagerNum == totalPagers) { pagerNum = 0; } // Remove active class from pagers $('[id^="views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '"]').removeClass('active'); // Add active class to active pager. $('#views_slideshow_pager_field_item_' + pagerLocation + '_' + options.slideshowID + '_' + slideNum).addClass('active'); } }; /** * Views Slideshow Slide Counter */ Drupal.viewsSlideshowSlideCounter = Drupal.viewsSlideshowSlideCounter || {}; /** * Implement the transitionBegin for the slide counter. */ Drupal.viewsSlideshowSlideCounter.transitionBegin = function (options) { $('#views_slideshow_slide_counter_' + options.slideshowID + ' .num').text(options.slideNum + 1); }; /** * This is used as a router to process actions for the slideshow. */ Drupal.viewsSlideshow.action = function (options) { // Set default values for our return status. var status = { 'value': true, 'text': '' }; // If an action isn't specified return false. if (typeof options.action == 'undefined' || options.action == '') { status.value = false; status.text = Drupal.t('There was no action specified.'); return error; } // If we are using pause or play switch paused state accordingly. if (options.action == 'pause') { drupalSettings.viewsSlideshow[options.slideshowID].paused = 1; // If the calling method is forcing a pause then mark it as such. if (options.force) { drupalSettings.viewsSlideshow[options.slideshowID].pausedForce = 1; } } else if (options.action == 'play') { // If the slideshow isn't forced pause or we are forcing a play then play // the slideshow. // Otherwise return telling the calling method that it was forced paused. if (!drupalSettings.viewsSlideshow[options.slideshowID].pausedForce || options.force) { drupalSettings.viewsSlideshow[options.slideshowID].paused = 0; drupalSettings.viewsSlideshow[options.slideshowID].pausedForce = 0; } else { status.value = false; status.text += ' ' + Drupal.t('This slideshow is forced paused.'); return status; } } // We use a switch statement here mainly just to limit the type of actions // that are available. switch (options.action) { case "goToSlide": case "transitionBegin": case "transitionEnd": // The three methods above require a slide number. Checking if it is // defined and it is a number that is an integer. if (typeof options.slideNum == 'undefined' || typeof options.slideNum !== 'number' || parseInt(options.slideNum) != (options.slideNum - 0)) { status.value = false; status.text = Drupal.t('An invalid integer was specified for slideNum.'); } case "pause": case "play": case "nextSlide": case "previousSlide": // Grab our list of methods. var methods = drupalSettings.viewsSlideshow[options.slideshowID]['methods']; // if the calling method specified methods that shouldn't be called then // exclude calling them. var excludeMethodsObj = {}; if (typeof options.excludeMethods !== 'undefined') { // We need to turn the excludeMethods array into an object so we can use the in // function. for (var i=0; i < excludeMethods.length; i++) { excludeMethodsObj[excludeMethods[i]] = ''; } } // Call every registered method and don't call excluded ones. for (i = 0; i < methods[options.action].length; i++) { if (Drupal[methods[options.action][i]] != undefined && typeof Drupal[methods[options.action][i]][options.action] == 'function' && !(methods[options.action][i] in excludeMethodsObj)) { Drupal[methods[options.action][i]][options.action](options); } } break; // If it gets here it's because it's an invalid action. default: status.value = false; status.text = Drupal.t('An invalid action "!action" was specified.', { "!action": options.action }); } return status; }; })(jQuery, Drupal, drupalSettings); ;