Linux cesa-www-main 6.1.0-49-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64
Apache/2.4.68 (Debian)
Server IP : 10.218.0.2 & Your IP : 216.73.216.28
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
var /
www /
cesa.co.za /
wp-content /
themes /
CESA New /
Delete
Unzip
Name
Size
Permission
Date
Action
sites
[ DIR ]
drwxr-sr-x
2020-03-20 05:34
Footer.php
2.81
KB
-rw-r--r--
2025-01-30 10:04
Header.php
4.22
KB
-rw-r--r--
2025-01-30 10:04
functions.php
158
B
-rw-r--r--
2025-01-30 10:04
index.php
995
B
-rw-r--r--
2025-01-30 10:04
js_1.js
104.74
KB
-rw-r--r--
2025-01-30 10:04
js_2.js
922.22
KB
-rw-r--r--
2025-01-30 10:04
js_3.js
175.87
KB
-rw-r--r--
2025-01-30 10:04
js_4.js
52.09
KB
-rw-r--r--
2025-01-30 10:04
js_5.js
1.7
KB
-rw-r--r--
2025-01-30 10:04
sidebar.php
1.33
KB
-rw-r--r--
2025-01-30 10:04
style.css
151.47
KB
-rw-r--r--
2025-01-30 10:04
style_2.css
10.18
KB
-rw-r--r--
2025-01-30 10:04
style_3.css
16.35
KB
-rw-r--r--
2025-01-30 10:04
style_4.css
11.07
KB
-rw-r--r--
2025-01-30 10:04
style_5.css
13.5
KB
-rw-r--r--
2025-01-30 10:04
style_6.css
80.71
KB
-rw-r--r--
2025-01-30 10:04
Save
Rename
// JavaScript Document// JavaScript Document(function ($) { Drupal.behaviors.grid_debug = { attach: function (context, settings) { $('a#switchgrid').click(function() { $("body").toggleClass('show-grid'); $(this).toggleClass('off'); return false; }); } }; })(jQuery); ; (function ($) { Drupal.behaviors.fidic_theme_car_tooltip = { attach: function (context, settings) { $("#block-commerce-cart-cart .cart-contents .view-content").hide(); $("#block-commerce-cart-cart").each(function(){ var text = $(this).find(".cart-contents .view-content").html(); if (text) { $(this).qtip({ content : text, style: { classes: 'ui-tooltip-light ui-tooltip-shadow ui-tooltip-rounded ui-tooltip-cart-content' }, position: { target: 'mouse', adjust: { x: 10, y: 10 } } }); } }); } }; })(jQuery); ; /*! * jQuery UI 1.8.7 * * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI */ (function(c,j){function k(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.7",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106, NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this, "position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position"); if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,l,m){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(l)g-=parseFloat(c.curCSS(f, "border"+this+"Width",true))||0;if(m)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h, d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){var b=a.nodeName.toLowerCase(),d=c.attr(a,"tabindex");if("area"===b){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&k(a)}return(/input|select|textarea|button|object/.test(b)?!a.disabled:"a"==b?a.href||!isNaN(d):!isNaN(d))&&k(a)},tabbable:function(a){var b=c.attr(a,"tabindex");return(isNaN(b)||b>=0)&&c(a).is(":focusable")}}); c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e<b.length;e++)a.options[b[e][0]]&& b[e][1].apply(a.element,d)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(a,b){if(c(a).css("overflow")==="hidden")return false;b=b&&b==="left"?"scrollLeft":"scrollTop";var d=false;if(a[b]>0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a<b+d},isOver:function(a,b,d,e,h,i){return c.ui.isOverAxis(a,d,h)&&c.ui.isOverAxis(b,e,i)}})}})(jQuery); ; /*! * jQuery UI Widget 1.8.7 * * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Widget */ (function(b,j){if(b.cleanData){var k=b.cleanData;b.cleanData=function(a){for(var c=0,d;(d=a[c])!=null;c++)b(d).triggerHandler("remove");k(a)}}else{var l=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add([this]).each(function(){b(this).triggerHandler("remove")});return l.call(b(this),a,c)})}}b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=function(h){return!!b.data(h, a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend(true,{},c.options);b[e][a].prototype=b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):d;if(e&&d.charAt(0)==="_")return h; e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==j){h=i;return false}}):this.each(function(){var g=b.data(this,a);g?g.option(d||{})._init():b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){b.data(c,this.widgetName,this);this.element=b(c);this.options=b.extend(true,{},this.options, this._getCreateOptions(),a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")}, widget:function(){return this.element},option:function(a,c){var d=a;if(arguments.length===0)return b.extend({},this.options);if(typeof a==="string"){if(c===j)return this.options[a];d={};d[a]=c}this._setOptions(d);return this},_setOptions:function(a){var c=this;b.each(a,function(d,e){c._setOption(d,e)});return this},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",c);return this}, enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery); ; /* * qTip2 - Pretty powerful tooltips * http://craigsworks.com/projects/qtip2/ * * Version: 2.0.0pre * Copyright 2009-2010 Craig Michael Thompson - http://craigsworks.com * * Dual licensed under MIT or GPLv2 licenses * http://en.wikipedia.org/wiki/MIT_License * http://en.wikipedia.org/wiki/GNU_General_Public_License * * Date: Fri Aug 19 08:14:39 2011 +0100 */ /*jslint browser: true, onevar: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true */ /*global window: false, jQuery: false, console: false */ (function($, window, undefined) { "use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ // Munge the primitives - Paul Irish tip var TRUE = true, FALSE = false, NULL = null, // Shortcut vars QTIP, PLUGINS, MOUSE, usedIDs = {}, uitooltip = 'ui-tooltip', widget = 'ui-widget', disabled = 'ui-state-disabled', selector = 'div.qtip.'+uitooltip, defaultClass = uitooltip + '-default', focusClass = uitooltip + '-focus', hoverClass = uitooltip + '-hover', fluidClass = uitooltip + '-fluid', hideOffset = '-31000px', replaceSuffix = '_replacedByqTip', oldtitle = 'oldtitle', trackingBound; /* Thanks to Paul Irish for this one: http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/ */ function log() { log.history = log.history || []; log.history.push(arguments); // Make sure console is present if('object' === typeof console) { // Setup console and arguments var c = console[ console.warn ? 'warn' : 'log' ], args = Array.prototype.slice.call(arguments), a; // Add qTip2 marker to first argument if it's a string if(typeof arguments[0] === 'string') { args[0] = 'qTip2: ' + args[0]; } // Apply console.warn or .log if not supported a = c.apply ? c.apply(console, args) : c(args); } } // Option object sanitizer function sanitizeOptions(opts) { var content; if(!opts || 'object' !== typeof opts) { return FALSE; } if('object' !== typeof opts.metadata) { opts.metadata = { type: opts.metadata }; } if('content' in opts) { if('object' !== typeof opts.content || opts.content.jquery) { opts.content = { text: opts.content }; } content = opts.content.text || FALSE; if(!$.isFunction(content) && ((!content && !content.attr) || content.length < 1 || ('object' === typeof content && !content.jquery))) { opts.content.text = FALSE; } if('title' in opts.content) { if('object' !== typeof opts.content.title) { opts.content.title = { text: opts.content.title }; } content = opts.content.title.text || FALSE; if(!$.isFunction(content) && ((!content && !content.attr) || content.length < 1 || ('object' === typeof content && !content.jquery))) { opts.content.title.text = FALSE; } } } if('position' in opts) { if('object' !== typeof opts.position) { opts.position = { my: opts.position, at: opts.position }; } } if('show' in opts) { if('object' !== typeof opts.show) { if(opts.show.jquery) { opts.show = { target: opts.show }; } else { opts.show = { event: opts.show }; } } } if('hide' in opts) { if('object' !== typeof opts.hide) { if(opts.hide.jquery) { opts.hide = { target: opts.hide }; } else { opts.hide = { event: opts.hide }; } } } if('style' in opts) { if('object' !== typeof opts.style) { opts.style = { classes: opts.style }; } } // Sanitize plugin options $.each(PLUGINS, function() { if(this.sanitize) { this.sanitize(opts); } }); return opts; } /* * Core plugin implementation */ function QTip(target, options, id, attr) { // Declare this reference var self = this, docBody = document.body, tooltipID = uitooltip + '-' + id, isPositioning = 0, isDrawing = 0, tooltip = $(), namespace = '.qtip-' + id, elements, cache; // Setup class attributes self.id = id; self.rendered = FALSE; self.elements = elements = { target: target }; self.timers = { img: {} }; self.options = options; self.checks = {}; self.plugins = {}; self.cache = cache = { event: {}, target: $(), disabled: FALSE, attr: attr }; /* * Private core functions */ function convertNotation(notation) { var i = 0, obj, option = options, // Split notation into array levels = notation.split('.'); // Loop through while( option = option[ levels[i++] ] ) { if(i < levels.length) { obj = option; } } return [obj || options, levels.pop()]; } function setWidget() { var on = options.style.widget; tooltip.toggleClass(widget, on).toggleClass(defaultClass, !on); elements.content.toggleClass(widget+'-content', on); if(elements.titlebar){ elements.titlebar.toggleClass(widget+'-header', on); } if(elements.button){ elements.button.toggleClass(uitooltip+'-icon', !on); } } function removeTitle(reposition) { if(elements.title) { elements.titlebar.remove(); elements.titlebar = elements.title = elements.button = NULL; // Reposition if enabled if(reposition !== FALSE) { self.reposition(); } } } function createButton() { var button = options.content.title.button, isString = typeof button === 'string', close = isString ? button : 'Close tooltip'; if(elements.button) { elements.button.remove(); } // Use custom button if one was supplied by user, else use default if(button.jquery) { elements.button = button; } else { elements.button = $('<a />', { 'class': 'ui-state-default ' + (options.style.widget ? '' : uitooltip+'-icon'), 'title': close, 'aria-label': close }) .prepend( $('<span />', { 'class': 'ui-icon ui-icon-close', 'html': '×' }) ); } // Create button and setup attributes elements.button.appendTo(elements.titlebar) .attr('role', 'button') .hover(function(event){ $(this).toggleClass('ui-state-hover', event.type === 'mouseenter'); }) .click(function(event) { if(!tooltip.hasClass(disabled)) { self.hide(event); } return FALSE; }) .bind('mousedown keydown mouseup keyup mouseout', function(event) { $(this).toggleClass('ui-state-active ui-state-focus', event.type.substr(-4) === 'down'); }); // Redraw the tooltip when we're done self.redraw(); } function createTitle() { var id = tooltipID+'-title'; // Destroy previous title element, if present if(elements.titlebar) { removeTitle(); } // Create title bar and title elements elements.titlebar = $('<div />', { 'class': uitooltip + '-titlebar ' + (options.style.widget ? 'ui-widget-header' : '') }) .append( elements.title = $('<div />', { 'id': id, 'class': uitooltip + '-title', 'aria-atomic': TRUE }) ) .insertBefore(elements.content); // Create button if enabled if(options.content.title.button) { createButton(); } // Redraw the tooltip dimensions if it's rendered else if(self.rendered){ self.redraw(); } } function updateButton(button) { var elem = elements.button, title = elements.title; // Make sure tooltip is rendered and if not, return if(!self.rendered) { return FALSE; } if(!button) { elem.remove(); } else { if(!title) { createTitle(); } createButton(); } } function updateTitle(content, reposition) { var elem = elements.title; // Make sure tooltip is rendered and if not, return if(!self.rendered || !content) { return FALSE; } // Use function to parse content if($.isFunction(content)) { content = content.call(target, cache.event, self); } // Remove title if callback returns false if(content === FALSE) { return removeTitle(FALSE); } // Append new content if its a DOM array and show it if hidden else if(content.jquery && content.length > 0) { elem.empty().append(content.css({ display: 'block' })); } // Content is a regular string, insert the new content else { elem.html(content); } // Redraw and reposition self.redraw(); if(reposition !== FALSE && self.rendered && tooltip.is(':visible')) { self.reposition(cache.event); } } function updateContent(content, reposition) { var elem = elements.content; // Make sure tooltip is rendered and content is defined. If not return if(!self.rendered || !content) { return FALSE; } // Use function to parse content if($.isFunction(content)) { content = content.call(target, cache.event, self) || ''; } // Append new content if its a DOM array and show it if hidden if(content.jquery && content.length > 0) { elem.empty().append(content.css({ display: 'block' })); } // Content is a regular string, insert the new content else { elem.html(content); } // Image detection function detectImages(next) { var images, srcs = {}; function imageLoad(image) { // Clear src from object and any timers and events associated with the image if(image) { delete srcs[image.src]; clearTimeout(self.timers.img[image.src]); $(image).unbind(namespace); } // If queue is empty after image removal, update tooltip and continue the queue if($.isEmptyObject(srcs)) { self.redraw(); if(reposition !== FALSE) { self.reposition(cache.event); } next(); } } // Find all content images without dimensions, and if no images were found, continue if((images = elem.find('img:not([height]):not([width])')).length === 0) { return imageLoad(); } // Apply timer to each image to poll for dimensions images.each(function(i, elem) { // Skip if the src is already present if(srcs[elem.src] !== undefined) { return; } (function timer(){ // When the dimensions are found, remove the image from the queue if(elem.height || elem.width) { return imageLoad(elem); } // Restart timer self.timers.img[elem.src] = setTimeout(timer, 700); }()); // Also apply regular load/error event handlers $(elem).bind('error'+namespace+' load'+namespace, function(){ imageLoad(this); }); // Store the src and element in our object srcs[elem.src] = elem; }); } /* * If we're still rendering... insert into 'fx' queue our image dimension * checker which will halt the showing of the tooltip until image dimensions * can be detected properly. */ if(self.rendered < 0) { tooltip.queue('fx', detectImages); } // We're fully rendered, so reset isDrawing flag and proceed without queue delay else { isDrawing = 0; detectImages($.noop); } return self; } function assignEvents() { var posOptions = options.position, targets = { show: options.show.target, hide: options.hide.target, viewport: $(posOptions.viewport), document: $(document), window: $(window) }, events = { show: $.trim('' + options.show.event).split(' '), hide: $.trim('' + options.hide.event).split(' ') }, IE6 = $.browser.msie && parseInt($.browser.version, 10) === 6; // Define show event method function showMethod(event) { if(tooltip.hasClass(disabled)) { return FALSE; } // If set, hide tooltip when inactive for delay period targets.show.trigger('qtip-'+id+'-inactive'); // Clear hide timers clearTimeout(self.timers.show); clearTimeout(self.timers.hide); // Start show timer var callback = function(){ self.toggle(TRUE, event); }; if(options.show.delay > 0) { self.timers.show = setTimeout(callback, options.show.delay); } else{ callback(); } } // Define hide method function hideMethod(event) { if(tooltip.hasClass(disabled) || isPositioning || isDrawing) { return FALSE; } // Check if new target was actually the tooltip element var relatedTarget = $(event.relatedTarget || event.target), ontoTooltip = relatedTarget.closest(selector)[0] === tooltip[0], ontoTarget = relatedTarget[0] === targets.show[0]; // Clear timers and stop animation queue clearTimeout(self.timers.show); clearTimeout(self.timers.hide); // Prevent hiding if tooltip is fixed and event target is the tooltip. Or if mouse positioning is enabled and cursor momentarily overlaps if((posOptions.target === 'mouse' && ontoTooltip) || (options.hide.fixed && ((/mouse(out|leave|move)/).test(event.type) && (ontoTooltip || ontoTarget)))) { event.preventDefault(); event.stopImmediatePropagation(); return; } // If tooltip has displayed, start hide timer if(options.hide.delay > 0) { self.timers.hide = setTimeout(function(){ self.hide(event); }, options.hide.delay); } else{ self.hide(event); } } // Define inactive method function inactiveMethod(event) { if(tooltip.hasClass(disabled)) { return FALSE; } // Clear timer clearTimeout(self.timers.inactive); self.timers.inactive = setTimeout(function(){ self.hide(event); }, options.hide.inactive); } function repositionMethod(event) { if(tooltip.is(':visible')) { self.reposition(event); } } // On mouseenter/mouseleave... tooltip.bind('mouseenter'+namespace+' mouseleave'+namespace, function(event) { var state = event.type === 'mouseenter'; // Focus the tooltip on mouseenter (z-index stacking) if(state) { self.focus(event); } // Add hover class tooltip.toggleClass(hoverClass, state); }); // Enable hide.fixed if(options.hide.fixed) { // Add tooltip as a hide target targets.hide = targets.hide.add(tooltip); // Clear hide timer on tooltip hover to prevent it from closing tooltip.bind('mouseover'+namespace, function() { if(!tooltip.hasClass(disabled)) { clearTimeout(self.timers.hide); } }); } // If using mouseout/mouseleave as a hide event... if(/mouse(out|leave)/i.test(options.hide.event)) { // Hide tooltips when leaving current window/frame (but not select/option elements) if(options.hide.leave === 'window') { targets.window.bind('mouseout' + namespace, function(event) { if(/select|option/.test(event.target) && !event.relatedTarget) { self.hide(event); } }); } } /* * Make sure hoverIntent functions properly by using mouseleave to clear show timer if * mouseenter/mouseout is used for show.event, even if it isn't in the users options. */ else if(/mouse(over|enter)/i.test(options.show.event)) { targets.hide.bind('mouseleave'+namespace, function(event) { clearTimeout(self.timers.show); }); } // Hide tooltip on document mousedown if unfocus events are enabled if(('' + options.hide.event).indexOf('unfocus') > -1) { targets.document.bind('mousedown'+namespace, function(event) { var $target = $(event.target), enabled = !tooltip.hasClass(disabled) && tooltip.is(':visible'); if($target[0] !== tooltip[0] && $target.parents(selector).length === 0 && $target.add(target).length > 1) { self.hide(event); } }); } // Check if the tooltip hides when inactive if('number' === typeof options.hide.inactive) { // Bind inactive method to target as a custom event targets.show.bind('qtip-'+id+'-inactive', inactiveMethod); // Define events which reset the 'inactive' event handler $.each(QTIP.inactiveEvents, function(index, type){ targets.hide.add(elements.tooltip).bind(type+namespace+'-inactive', inactiveMethod); }); } // Apply hide events $.each(events.hide, function(index, type) { var showIndex = $.inArray(type, events.show), targetHide = $(targets.hide); // Both events and targets are identical, apply events using a toggle if((showIndex > -1 && targetHide.add(targets.show).length === targetHide.length) || type === 'unfocus') { targets.show.bind(type+namespace, function(event) { if(tooltip.is(':visible')) { hideMethod(event); } else { showMethod(event); } }); // Don't bind the event again delete events.show[ showIndex ]; } // Events are not identical, bind normally else { targets.hide.bind(type+namespace, hideMethod); } }); // Apply show events $.each(events.show, function(index, type) { targets.show.bind(type+namespace, showMethod); }); // Check if the tooltip hides when mouse is moved a certain distance if('number' === typeof options.hide.distance) { // Bind mousemove to target to detect distance difference targets.show.add(tooltip).bind('mousemove'+namespace, function(event) { var origin = cache.origin || {}, limit = options.hide.distance, abs = Math.abs; // Check if the movement has gone beyond the limit, and hide it if so if(abs(event.pageX - origin.pageX) >= limit || abs(event.pageY - origin.pageY) >= limit) { self.hide(event); } }); } // Mouse positioning events if(posOptions.target === 'mouse') { // Cache mousemove coords on show targets targets.show.bind('mousemove'+namespace, function(event) { MOUSE = { pageX: event.pageX, pageY: event.pageY, type: 'mousemove' }; }); // If mouse adjustment is on... if(posOptions.adjust.mouse) { // Apply a mouseleave event so we don't get problems with overlapping if(options.hide.event) { tooltip.bind('mouseleave'+namespace, function(event) { if((event.relatedTarget || event.target) !== targets.show[0]) { self.hide(event); } }); } // Update tooltip position on mousemove targets.document.bind('mousemove'+namespace, function(event) { // Update the tooltip position only if the tooltip is visible and adjustment is enabled if(!tooltip.hasClass(disabled) && tooltip.is(':visible')) { self.reposition(event || MOUSE); } }); } } // Adjust positions of the tooltip on window resize if enabled if(posOptions.adjust.resize || targets.viewport.length) { ($.event.special.resize ? targets.viewport : targets.window).bind('resize'+namespace, repositionMethod); } // Adjust tooltip position on scroll if screen adjustment is enabled if(targets.viewport.length || (IE6 && tooltip.css('position') === 'fixed')) { targets.viewport.bind('scroll'+namespace, repositionMethod); } } function unassignEvents() { var targets = [ options.show.target[0], options.hide.target[0], self.rendered && elements.tooltip[0], options.position.container[0], options.position.viewport[0], window, document ]; // Check if tooltip is rendered if(self.rendered) { $([]).pushStack( $.grep(targets, function(i){ return typeof i === 'object'; }) ).unbind(namespace); } // Tooltip isn't yet rendered, remove render event else { options.show.target.unbind(namespace+'-create'); } } // Setup builtin .set() option checks self.checks.builtin = { // Core checks '^id$': function(obj, o, v) { var id = v === TRUE ? QTIP.nextid : v, tooltipID = uitooltip + '-' + id; if(id !== FALSE && id.length > 0 && !$('#'+tooltipID).length) { tooltip[0].id = tooltipID; elements.content[0].id = tooltipID + '-content'; elements.title[0].id = tooltipID + '-title'; } }, // Content checks '^content.text$': function(obj, o, v){ updateContent(v); }, '^content.title.text$': function(obj, o, v) { // Remove title if content is null if(!v) { return removeTitle(); } // If title isn't already created, create it now and update if(!elements.title && v) { createTitle(); } updateTitle(v); }, '^content.title.button$': function(obj, o, v){ updateButton(v); }, // Position checks '^position.(my|at)$': function(obj, o, v){ // Parse new corner value into Corner objecct if('string' === typeof v) { obj[o] = new PLUGINS.Corner(v); } }, '^position.container$': function(obj, o, v){ if(self.rendered) { tooltip.appendTo(v); } }, // Show checks '^show.ready$': function() { if(!self.rendered) { self.render(1); } else { self.toggle(TRUE); } }, // Style checks '^style.classes$': function(obj, o, v) { tooltip.attr('class', uitooltip + ' qtip ui-helper-reset ' + v); }, '^style.widget|content.title': setWidget, // Events check '^events.(render|show|move|hide|focus|blur)$': function(obj, o, v) { tooltip[($.isFunction(v) ? '' : 'un') + 'bind']('tooltip'+o, v); }, // Properties which require event reassignment '^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)': function() { var posOptions = options.position; // Set tracking flag tooltip.attr('tracking', posOptions.target === 'mouse' && posOptions.adjust.mouse); // Reassign events unassignEvents(); assignEvents(); } }; /* * Public API methods */ $.extend(self, { render: function(show) { if(self.rendered) { return self; } // If tooltip has already been rendered, exit var title = options.content.title.text, posOptions = options.position, callback = $.Event('tooltiprender'); // Add ARIA attributes to target $.attr(target[0], 'aria-describedby', tooltipID); // Create tooltip element tooltip = elements.tooltip = $('<div/>', { 'id': tooltipID, 'class': uitooltip + ' qtip ui-helper-reset ' + defaultClass + ' ' + options.style.classes, 'width': options.style.width || '', 'height': options.style.height || '', 'tracking': posOptions.target === 'mouse' && posOptions.adjust.mouse, /* ARIA specific attributes */ 'role': 'alert', 'aria-live': 'polite', 'aria-atomic': FALSE, 'aria-describedby': tooltipID + '-content', 'aria-hidden': TRUE }) .toggleClass(disabled, cache.disabled) .data('qtip', self) .appendTo(options.position.container) .append( // Create content element elements.content = $('<div />', { 'class': uitooltip + '-content', 'id': tooltipID + '-content', 'aria-atomic': TRUE }) ); // Set rendered flag and prevent redundant redraw/reposition calls for now self.rendered = -1; isDrawing = 1; isPositioning = 1; // Update title if(title) { createTitle(); updateTitle(title, FALSE); } // Set proper rendered flag and update content updateContent(options.content.text, FALSE); self.rendered = TRUE; // Setup widget classes setWidget(); // Assign passed event callbacks (before plugins!) $.each(options.events, function(name, callback) { if($.isFunction(callback)) { tooltip.bind(name === 'toggle' ? 'tooltipshow tooltiphide' : 'tooltip'+name, callback); } }); // Initialize 'render' plugins $.each(PLUGINS, function() { if(this.initialize === 'render') { this(self); } }); // Assign events assignEvents(); /* Queue this part of the render process in our fx queue so we can * load images before the tooltip renders fully. * * See: updateContent method */ tooltip.queue('fx', function(next) { // Trigger tooltiprender event and pass original triggering event as original callback.originalEvent = cache.event; tooltip.trigger(callback, [self]); // Reset flags isDrawing = 0; isPositioning = 0; // Redraw the tooltip manually now we're fully rendered self.redraw(); // Show tooltip if needed if(options.show.ready || show) { self.toggle(TRUE, cache.event); } next(); // Move on to next method in queue }); return self; }, get: function(notation) { var result, o; switch(notation.toLowerCase()) { case 'dimensions': result = { height: tooltip.outerHeight(), width: tooltip.outerWidth() }; break; case 'offset': result = PLUGINS.offset(tooltip, options.position.container); break; default: o = convertNotation(notation.toLowerCase()); result = o[0][ o[1] ]; result = result.precedance ? result.string() : result; break; } return result; }, set: function(option, value) { var rmove = /^position\.(my|at|adjust|target|container)|style|content|show\.ready/i, rdraw = /^content\.(title|attr)|style/i, reposition = FALSE, redraw = FALSE, checks = self.checks, name; function callback(notation, args) { var category, rule, match; for(category in checks) { for(rule in checks[category]) { if(match = (new RegExp(rule, 'i')).exec(notation)) { args.push(match); checks[category][rule].apply(self, args); } } } } // Convert singular option/value pair into object form if('string' === typeof option) { name = option; option = {}; option[name] = value; } else { option = $.extend(TRUE, {}, option); } // Set all of the defined options to their new values $.each(option, function(notation, value) { var obj = convertNotation( notation.toLowerCase() ), previous; // Set new obj value previous = obj[0][ obj[1] ]; obj[0][ obj[1] ] = 'object' === typeof value && value.nodeType ? $(value) : value; // Set the new params for the callback option[notation] = [obj[0], obj[1], value, previous]; // Also check if we need to reposition / redraw reposition = rmove.test(notation) || reposition; redraw = rdraw.test(notation) || redraw; }); // Re-sanitize options sanitizeOptions(options); /* * Execute any valid callbacks for the set options * Also set isPositioning/isDrawing so we don't get loads of redundant repositioning * and redraw calls. */ isPositioning = isDrawing = 1; $.each(option, callback); isPositioning = isDrawing = 0; // Update position / redraw if needed if(tooltip.is(':visible') && self.rendered) { if(reposition) { self.reposition( options.position.target === 'mouse' ? NULL : cache.event ); } if(redraw) { self.redraw(); } } return self; }, toggle: function(state, event) { // Make sure tooltip is rendered if(!self.rendered) { if(state) { self.render(1); } // Render the tooltip if showing and it isn't already else { return self; } } var type = state ? 'show' : 'hide', opts = options[type], visible = tooltip.is(':visible'), sameTarget = !event || options[type].target.length < 2 || cache.target[0] === event.target, posOptions = options.position, contentOptions = options.content, delay, callback; // Detect state if valid one isn't provided if((typeof state).search('boolean|number')) { state = !visible; } // Return if element is already in correct state if(!tooltip.is(':animated') && visible === state && sameTarget) { return self; } // Try to prevent flickering when tooltip overlaps show element if(event) { if((/over|enter/).test(event.type) && (/out|leave/).test(cache.event.type) && event.target === options.show.target[0] && tooltip.has(event.relatedTarget).length) { return self; } // Cache event cache.event = $.extend({}, event); } // Call API methods callback = $.Event('tooltip'+type); callback.originalEvent = event ? cache.event : NULL; tooltip.trigger(callback, [self, 90]); if(callback.isDefaultPrevented()){ return self; } // Set ARIA hidden status attribute $.attr(tooltip[0], 'aria-hidden', !!!state); // Execute state specific properties if(state) { // Store show origin coordinates cache.origin = $.extend({}, MOUSE); // Focus the tooltip self.focus(event); // Update tooltip content & title if it's a dynamic function if($.isFunction(contentOptions.text)) { updateContent(contentOptions.text, FALSE); } if($.isFunction(contentOptions.title.text)) { updateTitle(contentOptions.title.text, FALSE); } // Cache mousemove events for positioning purposes (if not already tracking) if(!trackingBound && posOptions.target === 'mouse' && posOptions.adjust.mouse) { $(document).bind('mousemove.qtip', function(event) { MOUSE = { pageX: event.pageX, pageY: event.pageY, type: 'mousemove' }; }); trackingBound = TRUE; } // Update the tooltip position self.reposition(event); // Hide other tooltips if tooltip is solo, using it as the context if(opts.solo) { $(selector, opts.solo).not(tooltip).qtip('hide', callback); } } else { // Clear show timer if we're hiding clearTimeout(self.timers.show); // Remove cached origin on hide delete cache.origin; // Remove mouse tracking event if not needed (all tracking qTips are hidden) if(trackingBound && !$(selector+'[tracking="true"]:visible', opts.solo).not(tooltip).length) { $(document).unbind('mousemove.qtip'); trackingBound = FALSE; } // Blur the tooltip self.blur(event); } // Define post-animation, state specific properties function after() { if(state) { // Prevent antialias from disappearing in IE by removing filter if($.browser.msie) { tooltip[0].style.removeAttribute('filter'); } // Remove overflow setting to prevent tip bugs tooltip.css('overflow', ''); // Autofocus elements if enabled if('string' === typeof opts.autofocus) { $(opts.autofocus, tooltip).focus(); } // Call API method callback = $.Event('tooltipvisible'); callback.originalEvent = event ? cache.event : NULL; tooltip.trigger(callback, [self]); } else { // Reset CSS states tooltip.css({ display: '', visibility: '', opacity: '', left: '', top: '' }); } } // Clear animation queue if same target if(sameTarget) { tooltip.stop(0, 1); } // If no effect type is supplied, use a simple toggle if(opts.effect === FALSE) { tooltip[ type ](); after.call(tooltip); } // Use custom function if provided else if($.isFunction(opts.effect)) { opts.effect.call(tooltip, self); tooltip.queue('fx', function(n){ after(); n(); }); } // Use basic fade function by default else { tooltip.fadeTo(90, state ? 1 : 0, after); } // If inactive hide method is set, active it if(state) { opts.target.trigger('qtip-'+id+'-inactive'); } return self; }, show: function(event){ return self.toggle(TRUE, event); }, hide: function(event){ return self.toggle(FALSE, event); }, focus: function(event) { if(!self.rendered) { return self; } var qtips = $(selector), curIndex = parseInt(tooltip[0].style.zIndex, 10), newIndex = QTIP.zindex + qtips.length, cachedEvent = $.extend({}, event), focusedElem, callback; // Only update the z-index if it has changed and tooltip is not already focused if(!tooltip.hasClass(focusClass)) { // Call API method callback = $.Event('tooltipfocus'); callback.originalEvent = cachedEvent; tooltip.trigger(callback, [self, newIndex]); // If default action wasn't prevented... if(!callback.isDefaultPrevented()) { // Only update z-index's if they've changed if(curIndex !== newIndex) { // Reduce our z-index's and keep them properly ordered qtips.each(function() { if(this.style.zIndex > curIndex) { this.style.zIndex = this.style.zIndex - 1; } }); // Fire blur event for focused tooltip qtips.filter('.' + focusClass).qtip('blur', cachedEvent); } // Set the new z-index tooltip.addClass(focusClass)[0].style.zIndex = newIndex; } } return self; }, blur: function(event) { var cachedEvent = $.extend({}, event), callback; // Set focused status to FALSE tooltip.removeClass(focusClass); // Trigger blur event callback = $.Event('tooltipblur'); callback.originalEvent = cachedEvent; tooltip.trigger(callback, [self]); return self; }, reposition: function(event, effect) { if(!self.rendered || isPositioning) { return self; } // Set positioning flag isPositioning = 1; var target = options.position.target, posOptions = options.position, my = posOptions.my, at = posOptions.at, adjust = posOptions.adjust, method = adjust.method.split(' '), elemWidth = tooltip.outerWidth(), elemHeight = tooltip.outerHeight(), targetWidth = 0, targetHeight = 0, callback = $.Event('tooltipmove'), fixed = tooltip.css('position') === 'fixed', viewport = posOptions.viewport, position = { left: 0, top: 0 }, tip = self.plugins.tip, readjust = { // Repositioning method and axis detection horizontal: method[0], vertical: method[1] || method[0], // Reposition methods left: function(posLeft) { var isShift = readjust.horizontal === 'shift', viewportScroll = viewport.offset.left + viewport.scrollLeft, myWidth = my.x === 'left' ? elemWidth : my.x === 'right' ? -elemWidth : -elemWidth / 2, atWidth = at.x === 'left' ? targetWidth : at.x === 'right' ? -targetWidth : -targetWidth / 2, tipWidth = tip && tip.size ? tip.size.width || 0 : 0, tipAdjust = tip && tip.corner && tip.corner.precedance === 'x' && !isShift ? tipWidth : 0, overflowLeft = viewportScroll - posLeft + tipAdjust, overflowRight = posLeft + elemWidth - viewport.width - viewportScroll + tipAdjust, offset = myWidth - (my.precedance === 'x' || my.x === my.y ? atWidth : 0), isCenter = my.x === 'center'; // Optional 'shift' style repositioning if(isShift) { tipAdjust = tip && tip.corner && tip.corner.precedance === 'y' ? tipWidth : 0; offset = (my.x === 'left' ? 1 : -1) * myWidth - tipAdjust; // Adjust position but keep it within viewport dimensions position.left += overflowLeft > 0 ? overflowLeft : overflowRight > 0 ? -overflowRight : 0; position.left = Math.max( viewport.offset.left + (tipAdjust && tip.corner.x === 'center' ? tip.offset : 0), posLeft - offset, Math.min( Math.max(viewport.offset.left + viewport.width, posLeft + offset), position.left ) ); } // Default 'flip' repositioning else { if(overflowLeft > 0 && (my.x !== 'left' || overflowRight > 0)) { position.left -= offset + (isCenter ? 0 : 2 * adjust.x); } else if(overflowRight > 0 && (my.x !== 'right' || overflowLeft > 0) ) { position.left -= isCenter ? -offset : offset + (2 * adjust.x); } if(position.left !== posLeft && isCenter) { position.left -= adjust.x; } // Make sure we haven't made things worse with the adjustment and return the adjusted difference if(position.left < viewportScroll && -position.left > overflowRight) { position.left = posLeft; } } return position.left - posLeft; }, top: function(posTop) { var isShift = readjust.vertical === 'shift', viewportScroll = viewport.offset.top + viewport.scrollTop, myHeight = my.y === 'top' ? elemHeight : my.y === 'bottom' ? -elemHeight : -elemHeight / 2, atHeight = at.y === 'top' ? targetHeight : at.y === 'bottom' ? -targetHeight : -targetHeight / 2, tipHeight = tip && tip.size ? tip.size.height || 0 : 0, tipAdjust = tip && tip.corner && tip.corner.precedance === 'y' && !isShift ? tipHeight : 0, overflowTop = viewportScroll - posTop + tipAdjust, overflowBottom = posTop + elemHeight - viewport.height - viewportScroll + tipAdjust, offset = myHeight - (my.precedance === 'y' || my.x === my.y ? atHeight : 0), isCenter = my.y === 'center'; // Optional 'shift' style repositioning if(isShift) { tipAdjust = tip && tip.corner && tip.corner.precedance === 'x' ? tipHeight : 0; offset = (my.y === 'top' ? 1 : -1) * myHeight - tipAdjust; // Adjust position but keep it within viewport dimensions position.top += overflowTop > 0 ? overflowTop : overflowBottom > 0 ? -overflowBottom : 0; position.top = Math.max( viewport.offset.top + (tipAdjust && tip.corner.x === 'center' ? tip.offset : 0), posTop - offset, Math.min( Math.max(viewport.offset.top + viewport.height, posTop + offset), position.top ) ); } // Default 'flip' repositioning else { if(overflowTop > 0 && (my.y !== 'top' || overflowBottom > 0)) { position.top -= offset + (isCenter ? 0 : 2 * adjust.y); } else if(overflowBottom > 0 && (my.y !== 'bottom' || overflowTop > 0) ) { position.top -= isCenter ? -offset : offset + (2 * adjust.y); } if(position.top !== posTop && isCenter) { position.top -= adjust.y; } // Make sure we haven't made things worse with the adjustment and return the adjusted difference if(position.top < 0 && -position.top > overflowBottom) { position.top = posTop; } } return position.top - posTop; } }; // Check if absolute position was passed if($.isArray(target) && target.length === 2) { // Force left top and set position at = { x: 'left', y: 'top' }; position = { left: target[0], top: target[1] }; } // Check if mouse was the target else if(target === 'mouse' && ((event && event.pageX) || cache.event.pageX)) { // Force left top to allow flipping at = { x: 'left', y: 'top' }; // Use cached event if one isn't available for positioning event = (event && (event.type === 'resize' || event.type === 'scroll') ? cache.event : event && event.pageX && event.type === 'mousemove' ? event : MOUSE && MOUSE.pageX && (adjust.mouse || !event || !event.pageX) ? { pageX: MOUSE.pageX, pageY: MOUSE.pageY } : !adjust.mouse && cache.origin && cache.origin.pageX ? cache.origin : event) || event || cache.event || MOUSE || {}; // Use event coordinates for position position = { top: event.pageY, left: event.pageX }; } // Target wasn't mouse or absolute... else { // Check if event targetting is being used if(target === 'event') { if(event && event.target && event.type !== 'scroll' && event.type !== 'resize') { target = cache.target = $(event.target); } else { target = cache.target; } } else { cache.target = $(target); } // Parse the target into a jQuery object and make sure there's an element present target = $(target).eq(0); if(target.length === 0) { return self; } // Check if window or document is the target else if(target[0] === document || target[0] === window) { targetWidth = PLUGINS.iOS ? window.innerWidth : target.width(); targetHeight = PLUGINS.iOS ? window.innerHeight : target.height(); if(target[0] === window) { position = { top: !fixed || PLUGINS.iOS ? (viewport || target).scrollTop() : 0, left: !fixed || PLUGINS.iOS ? (viewport || target).scrollLeft() : 0 }; } } // Use Imagemap/SVG plugins if needed else if(target.is('area') && PLUGINS.imagemap) { position = PLUGINS.imagemap(target, at); } else if(target[0].namespaceURI === 'http://www.w3.org/2000/svg' && PLUGINS.svg) { position = PLUGINS.svg(target, at); } else { targetWidth = target.outerWidth(); targetHeight = target.outerHeight(); position = PLUGINS.offset(target, posOptions.container, fixed); } // Parse returned plugin values into proper variables if(position.offset) { targetWidth = position.width; targetHeight = position.height; position = position.offset; } // Adjust position relative to target position.left += at.x === 'right' ? targetWidth : at.x === 'center' ? targetWidth / 2 : 0; position.top += at.y === 'bottom' ? targetHeight : at.y === 'center' ? targetHeight / 2 : 0; } // Adjust position relative to tooltip position.left += adjust.x + (my.x === 'right' ? -elemWidth : my.x === 'center' ? -elemWidth / 2 : 0); position.top += adjust.y + (my.y === 'bottom' ? -elemHeight : my.y === 'center' ? -elemHeight / 2 : 0); // Calculate collision offset values if viewport positioning is enabled if(viewport.jquery && target[0] !== window && target[0] !== docBody && readjust.vertical+readjust.horizontal !== 'nonenone') { // Cache our viewport details viewport = { elem: viewport, height: viewport[ (viewport[0] === window ? 'h' : 'outerH') + 'eight' ](), width: viewport[ (viewport[0] === window ? 'w' : 'outerW') + 'idth' ](), scrollLeft: fixed ? 0 : viewport.scrollLeft(), scrollTop: fixed ? 0 : viewport.scrollTop(), offset: viewport.offset() || { left: 0, top: 0 } }; // Adjust position based onviewport and adjustment options position.adjusted = { left: readjust.horizontal !== 'none' ? readjust.left(position.left) : 0, top: readjust.vertical !== 'none' ? readjust.top(position.top) : 0 }; } //Viewport adjustment is disabled, set values to zero else { position.adjusted = { left: 0, top: 0 }; } // Set tooltip position class tooltip.attr('class', function(i, val) { return $.attr(this, 'class').replace(/ui-tooltip-pos-\w+/i, ''); }) .addClass(uitooltip + '-pos-' + my.abbreviation()); // Call API method callback.originalEvent = $.extend({}, event); tooltip.trigger(callback, [self, position, viewport.elem || viewport]); if(callback.isDefaultPrevented()){ return self; } delete position.adjusted; // If effect is disabled, target it mouse, no animation is defined or positioning gives NaN out, set CSS directly if(effect === FALSE || isNaN(position.left) || isNaN(position.top) || target === 'mouse' || !$.isFunction(posOptions.effect)) { tooltip.css(position); } // Use custom function if provided else if($.isFunction(posOptions.effect)) { posOptions.effect.call(tooltip, self, $.extend({}, position)); tooltip.queue(function(next) { // Reset attributes to avoid cross-browser rendering bugs $(this).css({ opacity: '', height: '' }); if($.browser.msie) { this.style.removeAttribute('filter'); } next(); }); } // Set positioning flag isPositioning = 0; return self; }, // Max/min width simulator function for all browsers.. yeaaah! redraw: function() { if(self.rendered < 1 || isDrawing) { return self; } var container = options.position.container, perc, width, max, min; // Set drawing flag isDrawing = 1; // If tooltip has a set height, just set it... like a boss! if(options.style.height) { tooltip.css('height', options.style.height); } // If tooltip has a set width, just set it... like a boss! if(options.style.width) { tooltip.css('width', options.style.width); } // Otherwise simualte max/min width... else { // Reset width and add fluid class tooltip.css('width', '').addClass(fluidClass); // Grab our tooltip width (add 1 so we don't get wrapping problems.. huzzah!) width = tooltip.width() + 1; // Grab our max/min properties max = tooltip.css('max-width') || ''; min = tooltip.css('min-width') || ''; // Parse into proper pixel values perc = (max + min).indexOf('%') > -1 ? container.width() / 100 : 0; max = ((max.indexOf('%') > -1 ? perc : 1) * parseInt(max, 10)) || width; min = ((min.indexOf('%') > -1 ? perc : 1) * parseInt(min, 10)) || 0; // Determine new dimension size based on max/min/current values width = max + min ? Math.min(Math.max(width, min), max) : width; // Set the newly calculated width and remvoe fluid class tooltip.css('width', Math.round(width)).removeClass(fluidClass); } // Set drawing flag isDrawing = 0; return self; }, disable: function(state) { if('boolean' !== typeof state) { state = !(tooltip.hasClass(disabled) || cache.disabled); } if(self.rendered) { tooltip.toggleClass(disabled, state); $.attr(tooltip[0], 'aria-disabled', state); } else { cache.disabled = !!state; } return self; }, enable: function() { return self.disable(FALSE); }, destroy: function() { var t = target[0], title = $.attr(t, oldtitle); // Destroy tooltip and any associated plugins if rendered if(self.rendered) { tooltip.remove(); $.each(self.plugins, function() { if(this.destroy) { this.destroy(); } }); } // Clear timers and remove bound events clearTimeout(self.timers.show); clearTimeout(self.timers.hide); unassignEvents(); // Remove api object $.removeData(t, 'qtip'); // Reset old title attribute if removed if(options.suppress && title) { $.attr(t, 'title', title); target.removeAttr(oldtitle); } // Remove ARIA attributes and bound qtip events target.removeAttr('aria-describedby').unbind('.qtip'); // Remove ID from sued id object delete usedIDs[self.id]; return target; } }); } // Initialization method function init(id, opts) { var obj, posOptions, attr, config, title, // Setup element references elem = $(this), docBody = $(document.body), // Use document body instead of document element if needed newTarget = this === document ? docBody : elem, // Grab metadata from element if plugin is present metadata = (elem.metadata) ? elem.metadata(opts.metadata) : NULL, // If metadata type if HTML5, grab 'name' from the object instead, or use the regular data object otherwise metadata5 = opts.metadata.type === 'html5' && metadata ? metadata[opts.metadata.name] : NULL, // Grab data from metadata.name (or data-qtipopts as fallback) using .data() method, html5 = elem.data(opts.metadata.name || 'qtipopts'); // If we don't get an object returned attempt to parse it manualyl without parseJSON try { html5 = typeof html5 === 'string' ? (new Function("return " + html5))() : html5; } catch(e) { log('Unable to parse HTML5 attribute data: ' + html5); } // Merge in and sanitize metadata config = $.extend(TRUE, {}, QTIP.defaults, opts, typeof html5 === 'object' ? sanitizeOptions(html5) : NULL, sanitizeOptions(metadata5 || metadata)); // Re-grab our positioning options now we've merged our metadata and set id to passed value posOptions = config.position; config.id = id; // Setup missing content if none is detected if('boolean' === typeof config.content.text) { attr = elem.attr(config.content.attr); // Grab from supplied attribute if available if(config.content.attr !== FALSE && attr) { config.content.text = attr; } // No valid content was found, abort render else { log('Unable to locate content for tooltip! Aborting render of tooltip on element: ', elem); return FALSE; } } // Setup target options if(posOptions.container === FALSE) { posOptions.container = docBody; } if(posOptions.target === FALSE) { posOptions.target = newTarget; } if(config.show.target === FALSE) { config.show.target = newTarget; } if(config.show.solo === TRUE) { config.show.solo = docBody; } if(config.hide.target === FALSE) { config.hide.target = newTarget; } if(config.position.viewport === TRUE) { config.position.viewport = posOptions.container; } // Convert position corner values into x and y strings posOptions.at = new PLUGINS.Corner(posOptions.at); posOptions.my = new PLUGINS.Corner(posOptions.my); // Destroy previous tooltip if overwrite is enabled, or skip element if not if($.data(this, 'qtip')) { if(config.overwrite) { elem.qtip('destroy'); } else if(config.overwrite === FALSE) { return FALSE; } } // Remove title attribute and store it if present if(config.suppress && (title = $.attr(this, 'title'))) { $(this).removeAttr('title').attr(oldtitle, title); } // Initialize the tooltip and add API reference obj = new QTip(elem, config, id, !!attr); $.data(this, 'qtip', obj); // Catch remove events on target element to destroy redundant tooltip elem.bind('remove.qtip', function(){ obj.destroy(); }); return obj; } // jQuery $.fn extension method QTIP = $.fn.qtip = function(options, notation, newValue) { var command = ('' + options).toLowerCase(), // Parse command returned = NULL, args = command === 'disable' ? [TRUE] : $.makeArray(arguments).slice(1), event = args[args.length - 1], opts = this[0] ? $.data(this[0], 'qtip') : NULL; // Check for API request if((!arguments.length && opts) || command === 'api') { return opts; } // Execute API command if present else if('string' === typeof options) { this.each(function() { var api = $.data(this, 'qtip'); if(!api) { return TRUE; } // Cache the event if possible if(event && event.timeStamp) { api.cache.event = event; } // Check for specific API commands if((command === 'option' || command === 'options') && notation) { if($.isPlainObject(notation) || newValue !== undefined) { api.set(notation, newValue); } else { returned = api.get(notation); return FALSE; } } // Execute API command else if(api[command]) { api[command].apply(api[command], args); } }); return returned !== NULL ? returned : this; } // No API commands. validate provided options and setup qTips else if('object' === typeof options || !arguments.length) { opts = sanitizeOptions($.extend(TRUE, {}, options)); // Bind the qTips return QTIP.bind.call(this, opts, event); } }; // $.fn.qtip Bind method QTIP.bind = function(opts, event) { return this.each(function(i) { var options, targets, events, namespace, api, id; // Find next available ID, or use custom ID if provided id = $.isArray(opts.id) ? opts.id[i] : opts.id; id = !id || id === FALSE || id.length < 1 || usedIDs[id] ? QTIP.nextid++ : (usedIDs[id] = id); // Setup events namespace namespace = '.qtip-'+id+'-create'; // Initialize the qTip and re-grab newly sanitized options api = init.call(this, id, opts); if(api === FALSE) { return TRUE; } options = api.options; // Initialize plugins $.each(PLUGINS, function() { if(this.initialize === 'initialize') { this(api); } }); // Determine hide and show targets targets = { show: options.show.target, hide: options.hide.target }; events = { show: $.trim('' + options.show.event).replace(/ /g, namespace+' ') + namespace, hide: $.trim('' + options.hide.event).replace(/ /g, namespace+' ') + namespace }; /* * Make sure hoverIntent functions properly by using mouseleave as a hide event if * mouseenter/mouseout is used for show.event, even if it isn't in the users options. */ if(/mouse(over|enter)/i.test(events.show) && !/mouse(out|leave)/i.test(events.hide)) { events.hide += ' mouseleave' + namespace; } /* * Also make sure initial mouse targetting works correctly by caching mousemove coords * on show targets before the tooltip has rendered. */ targets.show.bind('mousemove'+namespace, function(event) { MOUSE = { pageX: event.pageX, pageY: event.pageY, type: 'mousemove' }; }); // Define hoverIntent function function hoverIntent(event) { function render() { // Cache mouse coords,render and render the tooltip api.render(typeof event === 'object' || options.show.ready); // Unbind show and hide events targets.show.add(targets.hide).unbind(namespace); } // Only continue if tooltip isn't disabled if(api.cache.disabled) { return FALSE; } // Cache the event data api.cache.event = $.extend({}, event); api.cache.target = event ? $(event.target) : [undefined]; // Start the event sequence if(options.show.delay > 0) { clearTimeout(api.timers.show); api.timers.show = setTimeout(render, options.show.delay); if(events.show !== events.hide) { targets.hide.bind(events.hide, function() { clearTimeout(api.timers.show); }); } } else { render(); } } // Bind show events to target targets.show.bind(events.show, hoverIntent); // Prerendering is enabled, create tooltip now if(options.show.ready || options.prerender) { hoverIntent(event); } }); }; // Setup base plugins PLUGINS = QTIP.plugins = { // Corner object parser Corner: function(corner) { corner = ('' + corner).replace(/([A-Z])/, ' $1').replace(/middle/gi, 'center').toLowerCase(); this.x = (corner.match(/left|right/i) || corner.match(/center/) || ['inherit'])[0].toLowerCase(); this.y = (corner.match(/top|bottom|center/i) || ['inherit'])[0].toLowerCase(); this.precedance = (corner.charAt(0).search(/^(t|b)/) > -1) ? 'y' : 'x'; this.string = function() { return this.precedance === 'y' ? this.y+this.x : this.x+this.y; }; this.abbreviation = function() { var x = this.x.substr(0,1), y = this.y.substr(0,1); return x === y ? x : (x === 'c' || (x !== 'c' && y !== 'c')) ? y + x : x + y; }; }, // Custom (more correct for qTip!) offset calculator offset: function(elem, container, fixed) { var pos = elem.offset(), parent = container, deep = 0, docBody = document.body, coffset; function scroll(e, i) { pos.left += i * e.scrollLeft(); pos.top += i * e.scrollTop(); } if(parent) { // Compensate for non-static containers offset do { if(parent.css('position') !== 'static') { coffset = parent[0] === docBody ? { left: parseInt(parent.css('left'), 10) || 0, top: parseInt(parent.css('top'), 10) || 0 } : parent.position(); pos.left -= coffset.left + (parseInt(parent.css('borderLeftWidth'), 10) || 0) + (parseInt(parent.css('marginLeft'), 10) || 0); pos.top -= coffset.top + (parseInt(parent.css('borderTopWidth'), 10) || 0); deep++; } if(parent[0] === docBody) { break; } } while(parent = parent.offsetParent()); // Compensate for containers scroll if it also has an offsetParent if(container[0] !== docBody && deep > 1) { scroll( container, 1 ); } // Adjust for position.fixed tooltips (and also iOS scroll bug in v3.2 - v4.0) if((PLUGINS.iOS < 4.1 && PLUGINS.iOS > 3.1) || (!PLUGINS.iOS && fixed)) { scroll( $(window), -1 ); } } return pos; }, /* * iOS 3.2 - 4.0 scroll fix detection used in offset() function. */ iOS: parseFloat( ('' + (/CPU.*OS ([0-9_]{1,3})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0,''])[1]) .replace('undefined', '3_2').replace('_','.') ) || FALSE, /* * jQuery-specific $.fn overrides */ fn: { /* Allow other plugins to successfully retrieve the title of an element with a qTip applied */ attr: function(attr, val) { if(this.length) { var self = this[0], title = 'title', api = $.data(self, 'qtip'); if(attr === title && 'object' === typeof api && api.options.suppress) { if(arguments.length < 2) { return $.attr(self, oldtitle); } else { // If qTip is rendered and title was originally used as content, update it if(api && api.options.content.attr === title && api.cache.attr) { api.set('content.text', val); } // Use the regular attr method to set, then cache the result return this.attr(oldtitle, val); } } } return $.fn['attr'+replaceSuffix].apply(this, arguments); }, /* Allow clone to correctly retrieve cached title attributes */ clone: function(keepData) { var titles = $([]), title = 'title', // Clone our element using the real clone method elems = $.fn['clone'+replaceSuffix].apply(this, arguments); // Grab all elements with an oldtitle set, and change it to regular title attribute, if keepData is false if(!keepData) { elems.filter('['+oldtitle+']').attr('title', function() { return $.attr(this, oldtitle); }) .removeAttr(oldtitle); } return elems; }, /* * Taken directly from jQuery 1.8.2 widget source code * Trigger 'remove' event on all elements on removal if jQuery UI isn't present */ remove: $.ui ? NULL : function( selector, keepData ) { $(this).each(function() { if (!keepData) { if (!selector || $.filter( selector, [ this ] ).length) { $('*', this).add(this).each(function() { $(this).triggerHandler('remove'); }); } } }); } } }; // Apply the fn overrides above $.each(PLUGINS.fn, function(name, func) { if(!func) { return TRUE; } var old = $.fn[name+replaceSuffix] = $.fn[name]; $.fn[name] = function() { return func.apply(this, arguments) || old.apply(this, arguments); }; }); // Set global qTip properties QTIP.version = '2.0.0pre'; QTIP.nextid = 0; QTIP.inactiveEvents = 'click dblclick mousedown mouseup mousemove mouseleave mouseenter'.split(' '); QTIP.zindex = 15000; // Define configuration defaults QTIP.defaults = { prerender: FALSE, id: FALSE, overwrite: TRUE, suppress: TRUE, content: { text: TRUE, attr: 'title', title: { text: FALSE, button: FALSE } }, position: { my: 'top left', at: 'bottom right', target: FALSE, container: FALSE, viewport: FALSE, adjust: { x: 0, y: 0, mouse: TRUE, resize: TRUE, method: 'flip flip' }, effect: function(api, pos, viewport) { $(this).animate(pos, { duration: 200, queue: FALSE }); } }, show: { target: FALSE, event: 'mouseenter', effect: TRUE, delay: 90, solo: FALSE, ready: FALSE, autofocus: FALSE }, hide: { target: FALSE, event: 'mouseleave', effect: TRUE, delay: 0, fixed: FALSE, inactive: FALSE, leave: 'window', distance: FALSE }, style: { classes: '', widget: FALSE, width: FALSE, height: FALSE }, events: { render: NULL, move: NULL, show: NULL, hide: NULL, toggle: NULL, visible: NULL, focus: NULL, blur: NULL } }; function Ajax(api) { var self = this, tooltip = api.elements.tooltip, opts = api.options.content.ajax, namespace = '.qtip-ajax', rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, first = TRUE; api.checks.ajax = { '^content.ajax': function(obj, name, v) { // If content.ajax object was reset, set our local var if(name === 'ajax') { opts = v; } if(name === 'once') { self.init(); } else if(opts && opts.url) { self.load(); } else { tooltip.unbind(namespace); } } }; $.extend(self, { init: function() { // Make sure ajax options are enabled and bind event if(opts && opts.url) { tooltip.unbind(namespace)[ opts.once ? 'one' : 'bind' ]('tooltipshow'+namespace, self.load); } return self; }, load: function(event, first) { // Make sure default event hasn't been prevented if(event && event.isDefaultPrevented()) { return self; } var hasSelector = opts.url.indexOf(' '), url = opts.url, selector, hideFirst = opts.once && !opts.loading && first; // If loading option is disabled, hide the tooltip until content is retrieved (first time only) if(hideFirst) { tooltip.css('visibility', 'hidden'); } // Check if user delcared a content selector like in .load() if(hasSelector > -1) { selector = url.substr(hasSelector); url = url.substr(0, hasSelector); } // Define common after callback for both success/error handlers function after() { // Re-display tip if loading and first time, and reset first flag if(hideFirst) { tooltip.css('visibility', ''); first = FALSE; } // Call users complete if it was defined if($.isFunction(opts.complete)) { opts.complete.apply(this, arguments); } } // Define success handler function successHandler(content) { if(selector) { // Create a dummy div to hold the results and grab the selector element content = $('<div/>') // inject the contents of the document in, removing the scripts // to avoid any 'Permission Denied' errors in IE .append(content.replace(rscript, "")) // Locate the specified elements .find(selector); } // Set the content api.set('content.text', content); } // Error handler function errorHandler(xh, status, error){ api.set('content.text', status + ': ' + error); } // Setup $.ajax option object and process the request $.ajax( $.extend({ success: successHandler, error: errorHandler, context: api }, opts, { url: url, complete: after }) ); return self; } }); self.init(); } PLUGINS.ajax = function(api) { var self = api.plugins.ajax; return 'object' === typeof self ? self : (api.plugins.ajax = new Ajax(api)); }; PLUGINS.ajax.initialize = 'render'; // Setup plugin sanitization PLUGINS.ajax.sanitize = function(options) { var content = options.content, opts; if(content && 'ajax' in content) { opts = content.ajax; if(typeof opts !== 'object') { opts = options.content.ajax = { url: opts }; } if('boolean' !== typeof opts.once && opts.once) { opts.once = !!opts.once; } } }; // Extend original api defaults $.extend(TRUE, QTIP.defaults, { content: { ajax: { loading: TRUE, once: TRUE } } }); /* * BGIFrame adaption (http://plugins.jquery.com/project/bgiframe) * Special thanks to Brandon Aaron */ function BGIFrame(api) { var self = this, elems = api.elements, tooltip = elems.tooltip, namespace = '.bgiframe-' + api.id; $.extend(self, { init: function() { // Create the BGIFrame element elems.bgiframe = $('<iframe class="ui-tooltip-bgiframe" frameborder="0" tabindex="-1" src="javascript:\'\';" ' + ' style="display:block; position:absolute; z-index:-1; filter:alpha(opacity=0); ' + '-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";"></iframe>'); // Append the new element to the tooltip elems.bgiframe.appendTo(tooltip); // Update BGIFrame on tooltip move tooltip.bind('tooltipmove'+namespace, self.adjust); }, adjust: function() { var dimensions = api.get('dimensions'), // Determine current tooltip dimensions plugin = api.plugins.tip, tip = elems.tip, tipAdjust, offset; // Adjust border offset offset = parseInt(tooltip.css('border-left-width'), 10) || 0; offset = { left: -offset, top: -offset }; // Adjust for tips plugin if(plugin && tip) { tipAdjust = (plugin.corner.precedance === 'x') ? ['width', 'left'] : ['height', 'top']; offset[ tipAdjust[1] ] -= tip[ tipAdjust[0] ](); } // Update bgiframe elems.bgiframe.css(offset).css(dimensions); }, destroy: function() { // Remove iframe elems.bgiframe.remove(); // Remove bound events tooltip.unbind(namespace); } }); self.init(); } PLUGINS.bgiframe = function(api) { var browser = $.browser, self = api.plugins.bgiframe; // Proceed only if the browser is IE6 and offending elements are present if($('select, object').length < 1 || !(browser.msie && browser.version.charAt(0) === '6')) { return FALSE; } return 'object' === typeof self ? self : (api.plugins.bgiframe = new BGIFrame(api)); }; // Plugin needs to be initialized on render PLUGINS.bgiframe.initialize = 'render'; PLUGINS.imagemap = function(area, corner) { if(!area.jquery) { area = $(area); } var shape = area.attr('shape').toLowerCase(), baseCoords = area.attr('coords').split(','), coords = [], image = $('img[usemap="#'+area.parent('map').attr('name')+'"]'), imageOffset = image.offset(), result = { width: 0, height: 0, offset: { top: 1e10, right: 0, bottom: 0, left: 1e10 } }, i = 0, next = 0; // POLY area coordinate calculator // Special thanks to Ed Cradock for helping out with this. // Uses a binary search algorithm to find suitable coordinates. function polyCoordinates(result, coords) { var i = 0, compareX = 1, compareY = 1, realX = 0, realY = 0, newWidth = result.width, newHeight = result.height; // Use a binary search algorithm to locate most suitable coordinate (hopefully) while(newWidth > 0 && newHeight > 0 && compareX > 0 && compareY > 0) { newWidth = Math.floor(newWidth / 2); newHeight = Math.floor(newHeight / 2); if(corner.x === 'left'){ compareX = newWidth; } else if(corner.x === 'right'){ compareX = result.width - newWidth; } else{ compareX += Math.floor(newWidth / 2); } if(corner.y === 'top'){ compareY = newHeight; } else if(corner.y === 'bottom'){ compareY = result.height - newHeight; } else{ compareY += Math.floor(newHeight / 2); } i = coords.length; while(i--) { if(coords.length < 2){ break; } realX = coords[i][0] - result.offset.left; realY = coords[i][1] - result.offset.top; if((corner.x === 'left' && realX >= compareX) || (corner.x === 'right' && realX <= compareX) || (corner.x === 'center' && (realX < compareX || realX > (result.width - compareX))) || (corner.y === 'top' && realY >= compareY) || (corner.y === 'bottom' && realY <= compareY) || (corner.y === 'center' && (realY < compareY || realY > (result.height - compareY)))) { coords.splice(i, 1); } } } return { left: coords[0][0], top: coords[0][1] }; } // Make sure we account for padding and borders on the image imageOffset.left += Math.ceil((image.outerWidth() - image.width()) / 2); imageOffset.top += Math.ceil((image.outerHeight() - image.height()) / 2); // Parse coordinates into proper array if(shape === 'poly') { i = baseCoords.length; while(i--) { next = [ parseInt(baseCoords[--i], 10), parseInt(baseCoords[i+1], 10) ]; if(next[0] > result.offset.right){ result.offset.right = next[0]; } if(next[0] < result.offset.left){ result.offset.left = next[0]; } if(next[1] > result.offset.bottom){ result.offset.bottom = next[1]; } if(next[1] < result.offset.top){ result.offset.top = next[1]; } coords.push(next); } } else { coords = $.map(baseCoords, function(coord){ return parseInt(coord, 10); }); } // Calculate details switch(shape) { case 'rect': result = { width: Math.abs(coords[2] - coords[0]), height: Math.abs(coords[3] - coords[1]), offset: { left: coords[0], top: coords[1] } }; break; case 'circle': result = { width: coords[2] + 2, height: coords[2] + 2, offset: { left: coords[0], top: coords[1] } }; break; case 'poly': $.extend(result, { width: Math.abs(result.offset.right - result.offset.left), height: Math.abs(result.offset.bottom - result.offset.top) }); if(corner.string() === 'centercenter') { result.offset = { left: result.offset.left + (result.width / 2), top: result.offset.top + (result.height / 2) }; } else { result.offset = polyCoordinates(result, coords.slice()); } result.width = result.height = 0; break; } // Add image position to offset coordinates result.offset.left += imageOffset.left; result.offset.top += imageOffset.top; return result; }; function Modal(api) { var self = this, options = api.options.show.modal, elems = api.elements, tooltip = elems.tooltip, overlaySelector = '#qtip-overlay', globalNamespace = '.qtipmodal', namespace = globalNamespace + api.id, attr = 'is-modal-qtip', docBody = $(document.body), overlay; // Setup option set checks api.checks.modal = { '^show.modal.(on|blur)$': function() { // Initialise self.init(); // Show the modal if not visible already and tooltip is visible elems.overlay.toggle( tooltip.is(':visible') ); } }; $.extend(self, { init: function() { // If modal is disabled... return if(!options.on) { return self; } // Create the overlay if needed overlay = self.create(); // Add unique attribute so we can grab modal tooltips easily via a selector tooltip.attr(attr, TRUE) .css('z-index', PLUGINS.modal.zindex + $(selector+'['+attr+']').length) // Remove previous bound events in globalNamespace .unbind(globalNamespace).unbind(namespace) // Apply our show/hide/focus modal events .bind('tooltipshow'+globalNamespace+' tooltiphide'+globalNamespace, function(event, api, duration) { var oEvent = event.originalEvent; // Make sure mouseout doesn't trigger a hide when showing the modal and mousing onto backdrop if(oEvent && event.type === 'tooltiphide' && /mouse(leave|enter)/.test(oEvent.type) && $(oEvent.relatedTarget).closest(overlay[0]).length) { event.preventDefault(); } else { self[ event.type.replace('tooltip', '') ](event, duration); } }) // Adjust modal z-index on tooltip focus .bind('tooltipfocus'+globalNamespace, function(event) { // If focus was cancelled before it reearch us, don't do anything if(event.isDefaultPrevented()) { return; } var qtips = $(selector).filter('['+attr+']'), // Keep the modal's lower than other, regular qtips newIndex = PLUGINS.modal.zindex + qtips.length, curIndex = parseInt(tooltip[0].style.zIndex, 10); // Set overlay z-index overlay[0].style.zIndex = newIndex; // Reduce modal z-index's and keep them properly ordered qtips.each(function() { if(this.style.zIndex > curIndex) { this.style.zIndex -= 1; } }); // Fire blur event for focused tooltip qtips.end().filter('.' + focusClass).qtip('blur', event.originalEvent); // Set the new z-index tooltip.addClass(focusClass)[0].style.zIndex = newIndex; // Prevent default handling event.preventDefault(); }) // Focus any other visible modals when this one hides .bind('tooltiphide'+globalNamespace, function(event) { $('[' + attr + ']').filter(':visible').not(tooltip).last().qtip('focus', event); }); // Apply keyboard "Escape key" close handler if(options.escape) { $(window).unbind(namespace).bind('keydown'+namespace, function(event) { if(event.keyCode === 27 && tooltip.hasClass(focusClass)) { api.hide(event); } }); } // Apply click handler for blur option if(options.blur) { elems.overlay.unbind(namespace).bind('click'+namespace, function(event) { if(tooltip.hasClass(focusClass)) { api.hide(event); } }); } return self; }, create: function() { var elem = $(overlaySelector); // Return if overlay is already rendered if(elem.length) { elems.overlay = elem; return elem; } // Create document overlay overlay = elems.overlay = $('<div />', { id: overlaySelector.substr(1), html: '<div></div>', mousedown: function() { return FALSE; } }) .insertBefore( $(selector).first() ); // Update position on window resize or scroll $(window).unbind(globalNamespace).bind('resize'+globalNamespace, function() { overlay.css({ height: $(window).height(), width: $(window).width() }); }) .triggerHandler('resize'); return overlay; }, toggle: function(event, state, duration) { // Make sure default event hasn't been prevented if(event && event.isDefaultPrevented()) { return self; } var effect = options.effect, type = state ? 'show': 'hide', visible = overlay.is(':visible'), modals = $('[' + attr + ']').filter(':visible').not(tooltip), zindex; // Create our overlay if it isn't present already if(!overlay) { overlay = self.create(); } // Prevent modal from conflicting with show.solo, and don't hide backdrop is other modals are visible if((overlay.is(':animated') && visible === state) || (!state && modals.length)) { return self; } // State specific... if(state) { // Set position overlay.css({ left: 0, top: 0 }); // Toggle backdrop cursor style on show overlay.toggleClass('blurs', options.blur); // Make sure we can't focus anything outside the tooltip docBody.delegate('*', 'focusin'+namespace, function(event) { if($(event.target).closest(selector)[0] !== tooltip[0]) { $('a, :input, img', tooltip).add(tooltip).focus(); } }); } else { // Undelegate focus handler docBody.undelegate('*', 'focusin'+namespace); } // Stop all animations overlay.stop(TRUE, FALSE); // Use custom function if provided if($.isFunction(effect)) { effect.call(overlay, state); } // If no effect type is supplied, use a simple toggle else if(effect === FALSE) { overlay[ type ](); } // Use basic fade function else { overlay.fadeTo( parseInt(duration, 10) || 90, state ? 1 : 0, function() { if(!state) { $(this).hide(); } }); } // Reset position on hide if(!state) { overlay.queue(function(next) { overlay.css({ left: '', top: '' }); next(); }); } return self; }, show: function(event, duration) { return self.toggle(event, TRUE, duration); }, hide: function(event, duration) { return self.toggle(event, FALSE, duration); }, destroy: function() { var delBlanket = overlay; if(delBlanket) { // Check if any other modal tooltips are present delBlanket = $('[' + attr + ']').not(tooltip).length < 1; // Remove overlay if needed if(delBlanket) { elems.overlay.remove(); $(window).unbind(globalNamespace); } else { elems.overlay.unbind(globalNamespace+api.id); } // Undelegate focus handler docBody.undelegate('*', 'focusin'+namespace); } // Remove bound events return tooltip.removeAttr(attr).unbind(globalNamespace); } }); self.init(); } PLUGINS.modal = function(api) { var self = api.plugins.modal; return 'object' === typeof self ? self : (api.plugins.modal = new Modal(api)); }; // Plugin needs to be initialized on render PLUGINS.modal.initialize = 'render'; // Setup sanitiztion rules PLUGINS.modal.sanitize = function(opts) { if(opts.show) { if(typeof opts.show.modal !== 'object') { opts.show.modal = { on: !!opts.show.modal }; } else if(typeof opts.show.modal.on === 'undefined') { opts.show.modal.on = TRUE; } } }; // Base z-index for all modal tooltips (use qTip core z-index as a base) PLUGINS.modal.zindex = QTIP.zindex -= 200; // Extend original api defaults $.extend(TRUE, QTIP.defaults, { show: { modal: { on: FALSE, effect: TRUE, blur: TRUE, escape: TRUE } } }); PLUGINS.svg = function(svg, corner) { var doc = $(document), elem = svg[0], result = { width: 0, height: 0, offset: { top: 1e10, left: 1e10 } }, box, mtx, root, point, tPoint; if (elem.getBBox && elem.parentNode) { box = elem.getBBox(); mtx = elem.getScreenCTM(); root = elem.farthestViewportElement || elem; // Return if no method is found if(!root.createSVGPoint) { return result; } // Create our point var point = root.createSVGPoint(); // Adjust top and left point.x = box.x; point.y = box.y; tPoint = point.matrixTransform(mtx); result.offset.left = tPoint.x; result.offset.top = tPoint.y; // Adjust width and height point.x += box.width; point.y += box.height; tPoint = point.matrixTransform(mtx); result.width = tPoint.x - result.offset.left; result.height = tPoint.y - result.offset.top; // Adjust by scroll offset result.offset.left += doc.scrollLeft(); result.offset.top += doc.scrollTop(); } return result; }; // Tip coordinates calculator function calculateTip(corner, width, height) { var width2 = Math.ceil(width / 2), height2 = Math.ceil(height / 2), // Define tip coordinates in terms of height and width values tips = { bottomright: [[0,0], [width,height], [width,0]], bottomleft: [[0,0], [width,0], [0,height]], topright: [[0,height], [width,0], [width,height]], topleft: [[0,0], [0,height], [width,height]], topcenter: [[0,height], [width2,0], [width,height]], bottomcenter: [[0,0], [width,0], [width2,height]], rightcenter: [[0,0], [width,height2], [0,height]], leftcenter: [[width,0], [width,height], [0,height2]] }; // Set common side shapes tips.lefttop = tips.bottomright; tips.righttop = tips.bottomleft; tips.leftbottom = tips.topright; tips.rightbottom = tips.topleft; return tips[ corner.string() ]; } function Tip(qTip, command) { var self = this, opts = qTip.options.style.tip, elems = qTip.elements, tooltip = elems.tooltip, cache = { top: 0, left: 0, corner: '' }, size = { width: opts.width, height: opts.height }, color = { }, border = opts.border || 0, namespace = '.qtip-tip', hasCanvas = !!($('<canvas />')[0] || {}).getContext; self.corner = NULL; self.mimic = NULL; self.border = border; self.offset = opts.offset; self.size = size; // Add new option checks for the plugin qTip.checks.tip = { '^position.my|style.tip.(corner|mimic|border)$': function() { // Make sure a tip can be drawn if(!self.init()) { self.destroy(); } // Reposition the tooltip qTip.reposition(); }, '^style.tip.(height|width)$': function() { // Re-set dimensions and redraw the tip size = { width: opts.width, height: opts.height }; self.create(); self.update(); // Reposition the tooltip qTip.reposition(); }, '^content.title.text|style.(classes|widget)$': function() { if(elems.tip) { self.update(); } } }; function reposition(event, api, pos, viewport) { if(!elems.tip) { return; } var newCorner = $.extend({}, self.corner), adjust = pos.adjusted, method = qTip.options.position.adjust.method.split(' '), horizontal = method[0], vertical = method[1] || method[0], shift = { left: FALSE, top: FALSE, x: 0, y: 0 }, offset, css = {}, props; // Make sure our tip position isn't fixed e.g. doesn't adjust with viewport if(self.corner.fixed !== TRUE) { // Horizontal - Shift or flip method if(horizontal === 'shift' && newCorner.precedance === 'x' && adjust.left && newCorner.y !== 'center') { newCorner.precedance = newCorner.precedance === 'x' ? 'y' : 'x'; } else if(horizontal === 'flip' && adjust.left){ newCorner.x = newCorner.x === 'center' ? (adjust.left > 0 ? 'left' : 'right') : (newCorner.x === 'left' ? 'right' : 'left'); } // Vertical - Shift or flip method if(vertical === 'shift' && newCorner.precedance === 'y' && adjust.top && newCorner.x !== 'center') { newCorner.precedance = newCorner.precedance === 'y' ? 'x' : 'y'; } else if(vertical === 'flip' && adjust.top) { newCorner.y = newCorner.y === 'center' ? (adjust.top > 0 ? 'top' : 'bottom') : (newCorner.y === 'top' ? 'bottom' : 'top'); } // Update and redraw the tip if needed (check cached details of last drawn tip) if(newCorner.string() !== cache.corner && (cache.top !== adjust.top || cache.left !== adjust.left)) { self.update(newCorner, FALSE); } } // Setup tip offset properties offset = self.position(newCorner, adjust); if(offset.right !== undefined) { offset.left = -offset.right; } if(offset.bottom !== undefined) { offset.top = -offset.bottom; } offset.user = Math.max(0, opts.offset); // Viewport "shift" specific adjustments if(shift.left = (horizontal === 'shift' && !!adjust.left)) { if(newCorner.x === 'center') { css['margin-left'] = shift.x = offset['margin-left'] - adjust.left; } else { props = offset.right !== undefined ? [ adjust.left, -offset.left ] : [ -adjust.left, offset.left ]; if( (shift.x = Math.max(props[0], props[1])) > props[0] ) { pos.left -= adjust.left; shift.left = FALSE; } css[ offset.right !== undefined ? 'right' : 'left' ] = shift.x; } } if(shift.top = (vertical === 'shift' && !!adjust.top)) { if(newCorner.y === 'center') { css['margin-top'] = shift.y = offset['margin-top'] - adjust.top; } else { props = offset.bottom !== undefined ? [ adjust.top, -offset.top ] : [ -adjust.top, offset.top ]; if( (shift.y = Math.max(props[0], props[1])) > props[0] ) { pos.top -= adjust.top; shift.top = FALSE; } css[ offset.bottom !== undefined ? 'bottom' : 'top' ] = shift.y; } } /* * If the tip is adjusted in both dimensions, or in a * direction that would cause it to be anywhere but the * outer border, hide it! */ elems.tip.css(css).toggle( !((shift.x && shift.y) || (newCorner.x === 'center' && shift.y) || (newCorner.y === 'center' && shift.x)) ); // Adjust position to accomodate tip dimensions pos.left -= offset.left.charAt ? offset.user : horizontal !== 'shift' || shift.top || !shift.left && !shift.top ? offset.left : 0; pos.top -= offset.top.charAt ? offset.user : vertical !== 'shift' || shift.left || !shift.left && !shift.top ? offset.top : 0; // Cache details cache.left = adjust.left; cache.top = adjust.top; cache.corner = newCorner.string(); } /* border width calculator */ function borderWidth(corner, side, backup) { side = !side ? corner[corner.precedance] : side; var isFluid = tooltip.hasClass(fluidClass), isTitleTop = elems.titlebar && corner.y === 'top', elem = isTitleTop ? elems.titlebar : elems.content, css = 'border-' + side + '-width', val; // Grab the border-width value (add fluid class if needed) tooltip.addClass(fluidClass); val = parseInt(elem.css(css), 10); val = (backup ? val || parseInt(tooltip.css(css), 10) : val) || 0; tooltip.toggleClass(fluidClass, isFluid); return val; } function borderRadius(corner) { var isTitleTop = elems.titlebar && corner.y === 'top', elem = isTitleTop ? elems.titlebar : elems.content, moz = $.browser.mozilla, prefix = moz ? '-moz-' : $.browser.webkit ? '-webkit-' : '', side = corner.y + (moz ? '' : '-') + corner.x, css = prefix + (moz ? 'border-radius-' + side : 'border-' + side + '-radius'); return parseInt(elem.css(css), 10) || parseInt(tooltip.css(css), 10) || 0; } function calculateSize(corner) { var y = corner.precedance === 'y', width = size [ y ? 'width' : 'height' ], height = size [ y ? 'height' : 'width' ], isCenter = corner.string().indexOf('center') > -1, base = width * (isCenter ? 0.5 : 1), pow = Math.pow, round = Math.round, bigHyp, ratio, result, smallHyp = Math.sqrt( pow(base, 2) + pow(height, 2) ), hyp = [ (border / base) * smallHyp, (border / height) * smallHyp ]; hyp[2] = Math.sqrt( pow(hyp[0], 2) - pow(border, 2) ); hyp[3] = Math.sqrt( pow(hyp[1], 2) - pow(border, 2) ); bigHyp = smallHyp + hyp[2] + hyp[3] + (isCenter ? 0 : hyp[0]); ratio = bigHyp / smallHyp; result = [ round(ratio * height), round(ratio * width) ]; return { height: result[ y ? 0 : 1 ], width: result[ y ? 1 : 0 ] }; } $.extend(self, { init: function() { var enabled = self.detectCorner() && (hasCanvas || $.browser.msie); // Determine tip corner and type if(enabled) { // Create a new tip and draw it self.create(); self.update(); // Bind update events tooltip.unbind(namespace).bind('tooltipmove'+namespace, reposition); } return enabled; }, detectCorner: function() { var corner = opts.corner, posOptions = qTip.options.position, at = posOptions.at, my = posOptions.my.string ? posOptions.my.string() : posOptions.my; // Detect corner and mimic properties if(corner === FALSE || (my === FALSE && at === FALSE)) { return FALSE; } else { if(corner === TRUE) { self.corner = new PLUGINS.Corner(my); } else if(!corner.string) { self.corner = new PLUGINS.Corner(corner); self.corner.fixed = TRUE; } } return self.corner.string() !== 'centercenter'; }, detectColours: function() { var i, fill, border, tip = elems.tip.css({ backgroundColor: '', border: '' }), corner = self.corner, precedance = corner[ corner.precedance ], borderSide = 'border-' + precedance + '-color', borderSideCamel = 'border' + precedance.charAt(0) + precedance.substr(1) + 'Color', invalid = /rgba?\(0, 0, 0(, 0)?\)|transparent/i, backgroundColor = 'background-color', transparent = 'transparent', bodyBorder = $(document.body).css('color'), contentColour = qTip.elements.content.css('color'), useTitle = elems.titlebar && (corner.y === 'top' || (corner.y === 'center' && tip.position().top + (size.height / 2) + opts.offset < elems.titlebar.outerHeight(1))), colorElem = useTitle ? elems.titlebar : elems.content; // Apply the fluid class so we can see our CSS values properly tooltip.addClass(fluidClass); // Detect tip colours from CSS styles color.fill = fill = tip.css(backgroundColor); color.border = border = tip[0].style[ borderSideCamel ] || tip.css(borderSide) || tooltip.css(borderSide); // Make sure colours are valid if(!fill || invalid.test(fill)) { color.fill = colorElem.css(backgroundColor) || transparent; if(invalid.test(color.fill)) { color.fill = tooltip.css(backgroundColor) || fill; } } if(!border || invalid.test(border) || border === bodyBorder) { color.border = colorElem.css(borderSide) || transparent; if(invalid.test(color.border) || color.border === contentColour) { color.border = border; } } // Reset background and border colours $('*', tip).add(tip).css(backgroundColor, transparent).css('border', ''); // Remove fluid class tooltip.removeClass(fluidClass); }, create: function() { var width = size.width, height = size.height, vml; // Remove previous tip element if present if(elems.tip) { elems.tip.remove(); } // Create tip element and prepend to the tooltip elems.tip = $('<div />', { 'class': 'ui-tooltip-tip' }).css({ width: width, height: height }).prependTo(tooltip); // Create tip drawing element(s) if(hasCanvas) { // save() as soon as we create the canvas element so FF2 doesn't bork on our first restore()! $('<canvas />').appendTo(elems.tip)[0].getContext('2d').save(); } else { vml = '<vml:shape coordorigin="0,0" style="display:inline-block; position:absolute; behavior:url(#default#VML);"></vml:shape>'; elems.tip.html(vml + vml); } }, update: function(corner, position) { var tip = elems.tip, inner = tip.children(), width = size.width, height = size.height, regular = 'px solid ', transparent = 'px dashed transparent', // Dashed IE6 border-transparency hack. Awesome! mimic = opts.mimic, round = Math.round, precedance, context, coords, translate, newSize; // Re-determine tip if not already set if(!corner) { corner = self.corner; } // Use corner property if we detect an invalid mimic value if(mimic === FALSE) { mimic = corner; } // Otherwise inherit mimic properties from the corner object as necessary else { mimic = new PLUGINS.Corner(mimic); mimic.precedance = corner.precedance; if(mimic.x === 'inherit') { mimic.x = corner.x; } else if(mimic.y === 'inherit') { mimic.y = corner.y; } else if(mimic.x === mimic.y) { mimic[ corner.precedance ] = corner[ corner.precedance ]; } } precedance = mimic.precedance; // Update our colours self.detectColours(); // Detect border width, taking into account colours if(color.border !== 'transparent' && color.border !== '#123456') { // Grab border width border = borderWidth(corner, NULL, TRUE); // If border width isn't zero, use border color as fill (1.0 style tips) if(opts.border === 0 && border > 0) { color.fill = color.border; } // Set border width (use detected border width if opts.border is true) self.border = border = opts.border !== TRUE ? opts.border : border; } // Border colour was invalid, set border to zero else { self.border = border = 0; } // Calculate coordinates coords = calculateTip(mimic, width , height); // Determine tip size self.size = newSize = calculateSize(corner); tip.css(newSize); // Calculate tip translation if(corner.precedance === 'y') { translate = [ round(mimic.x === 'left' ? border : mimic.x === 'right' ? newSize.width - width - border : (newSize.width - width) / 2), round(mimic.y === 'top' ? newSize.height - height : 0) ]; } else { translate = [ round(mimic.x === 'left' ? newSize.width - width : 0), round(mimic.y === 'top' ? border : mimic.y === 'bottom' ? newSize.height - height - border : (newSize.height - height) / 2) ]; } // Canvas drawing implementation if(hasCanvas) { // Set the canvas size using calculated size inner.attr(newSize); // Grab canvas context and clear/save it context = inner[0].getContext('2d'); context.restore(); context.save(); context.clearRect(0,0,3000,3000); // Translate origin context.translate(translate[0], translate[1]); // Draw the tip context.beginPath(); context.moveTo(coords[0][0], coords[0][1]); context.lineTo(coords[1][0], coords[1][1]); context.lineTo(coords[2][0], coords[2][1]); context.closePath(); context.fillStyle = color.fill; context.strokeStyle = color.border; context.lineWidth = border * 2; context.lineJoin = 'miter'; context.miterLimit = 100; if(border) { context.stroke(); } context.fill(); } // VML (IE Proprietary implementation) else { // Setup coordinates string coords = 'm' + coords[0][0] + ',' + coords[0][1] + ' l' + coords[1][0] + ',' + coords[1][1] + ' ' + coords[2][0] + ',' + coords[2][1] + ' xe'; // Setup VML-specific offset for pixel-perfection translate[2] = border && /^(r|b)/i.test(corner.string()) ? parseFloat($.browser.version, 10) === 8 ? 2 : 1 : 0; // Set initial CSS inner.css({ antialias: ''+(mimic.string().indexOf('center') > -1), left: translate[0] - (translate[2] * Number(precedance === 'x')), top: translate[1] - (translate[2] * Number(precedance === 'y')), width: width + border, height: height + border }) .each(function(i) { var $this = $(this); // Set shape specific attributes $this[ $this.prop ? 'prop' : 'attr' ]({ coordsize: (width+border) + ' ' + (height+border), path: coords, fillcolor: color.fill, filled: !!i, stroked: !!!i }) .css({ display: border || i ? 'block' : 'none' }); // Check if border is enabled and add stroke element if(!i && $this.html() === '') { $this.html( '<vml:stroke weight="'+(border*2)+'px" color="'+color.border+'" miterlimit="1000" joinstyle="miter" ' + ' style="behavior:url(#default#VML); display:inline-block;" />' ); } }); } // Position if needed if(position !== FALSE) { self.position(corner); } }, // Tip positioning method position: function(corner) { var tip = elems.tip, position = {}, userOffset = Math.max(0, opts.offset), precedance, dimensions, corners; // Return if tips are disabled or tip is not yet rendered if(opts.corner === FALSE || !tip) { return FALSE; } // Inherit corner if not provided corner = corner || self.corner; precedance = corner.precedance; // Determine which tip dimension to use for adjustment dimensions = calculateSize(corner); // Setup corners and offset array corners = [ corner.x, corner.y ]; if(precedance === 'x') { corners.reverse(); } // Calculate tip position $.each(corners, function(i, side) { var b, br; if(side === 'center') { b = precedance === 'y' ? 'left' : 'top'; position[ b ] = '50%'; position['margin-' + b] = -Math.round(dimensions[ precedance === 'y' ? 'width' : 'height' ] / 2) + userOffset; } else { b = borderWidth(corner, side, TRUE); br = borderRadius(corner); position[ side ] = i ? border ? borderWidth(corner, side) : 0 : userOffset + (br > b ? br : 0); } }); // Adjust for tip dimensions position[ corner[precedance] ] -= dimensions[ precedance === 'x' ? 'width' : 'height' ]; // Set and return new position tip.css({ top: '', bottom: '', left: '', right: '', margin: '' }).css(position); return position; }, destroy: function() { // Remov tip and bound events if(elems.tip) { elems.tip.remove(); } tooltip.unbind(namespace); } }); self.init(); } PLUGINS.tip = function(api) { var self = api.plugins.tip; return 'object' === typeof self ? self : (api.plugins.tip = new Tip(api)); }; // Initialize tip on render PLUGINS.tip.initialize = 'render'; // Setup plugin sanitization options PLUGINS.tip.sanitize = function(options) { var style = options.style, opts; if(style && 'tip' in style) { opts = options.style.tip; if(typeof opts !== 'object'){ options.style.tip = { corner: opts }; } if(!(/string|boolean/i).test(typeof opts.corner)) { opts.corner = TRUE; } if(typeof opts.width !== 'number'){ delete opts.width; } if(typeof opts.height !== 'number'){ delete opts.height; } if(typeof opts.border !== 'number' && opts.border !== TRUE){ delete opts.border; } if(typeof opts.offset !== 'number'){ delete opts.offset; } } }; // Extend original qTip defaults $.extend(TRUE, QTIP.defaults, { style: { tip: { corner: TRUE, mimic: FALSE, width: 6, height: 6, border: TRUE, offset: 0 } } }); }(jQuery, window));; (function ($) { Drupal.behaviors.qtip = { attach: function(context) { // Set delay on click to immediate if (Drupal.settings.qtip.show_event_type == 'click') { show_delay = 1; } else { show_delay = 140; // This is the default qTip value, set for hover links } // Determine how to position the tooltip if (Drupal.settings.qtip.show_speech_bubble_tip) { // Set the proper qtip speech-bubble tip position if (Drupal.settings.qtip.show_speech_bubble_tip_side) { switch_position = Drupal.settings.qtip.tooltip_position.split('_'); // We do not want to put tooltip on it's side if it is being displayed // in the center or side of an element if (switch_position[1] == 'center') { tip_position = Drupal.settings.qtip.tooltip_position; } else { tip_position = switch_position[1] + ' ' + switch_position[0]; } } // Otherwise just set it to the same value as the tooltip else { tip_position = Drupal.settings.qtip.tooltip_position; } } else { tip_position = false; } // Is a custom style declared by the admin? if(Drupal.settings.qtip.color == 'custom-color') { Drupal.settings.qtip.color = Drupal.settings.qtip.custom_color; } // Do we want a shadow to show under the tooltip? if(Drupal.settings.qtip.show_shadow) { style_classes = 'ui-tooltip-shadow ' + Drupal.settings.qtip.color; } else { style_classes = Drupal.settings.qtip.color; } // Do we want to show the tooltips with rounded corners? if(Drupal.settings.qtip.rounded_corners) { style_classes += ' ui-tooltip-rounded'; } //Do we want a solid tip to display if (Drupal.settings.qtip.show_speech_bubble_tip_solid) { solid_tip = false; } else { solid_tip = 5; } /*** Standard Settings ***/ $('.qtip-link').each(function() { if(Drupal.settings.qtip.show_event_type == 'click') { $(this).addClass('ui-tooltip-click'); } // if there is a title associated with this qtip... if ($(this).children('.qtip-header').length) { tooltip_title = $(this).children('.qtip-header').html(); } // if there isn't we don't want a blank title area to show on the qtip... else { tooltip_title = false; } build_qtip(this, 'node'); }); /*** Additional Elements ***/ if(Drupal.settings.qtip.additional_elements) { $(Drupal.settings.qtip.additional_elements).each(function() { $(this).addClass('qtip-additional-element'); if(Drupal.settings.qtip.show_event_type == 'click') { $(this).addClass('ui-tooltip-click'); } // if there is a title associated with this qtip... if ($(this).children('.qtip-header').length) { tooltip_title = $(this).children('.qtip-header').html(); } // if there isn't we don't want a blank title area to show on the qtip... else { tooltip_title = false; } build_qtip(this, 'node'); }); } /*** Webform Settings ***/ // Does the admin even want the descriptions to show up in a tooltip? if (Drupal.settings.qtip.show_webform_descriptions) { /* form-text - works well form-textarea - works, but width can throw off the tooltip form-radios - works, but the radios element wrapper is 100% width, so throws off tooltip like form-textarea form-select - works well - should maybe have something like mouseenter or something for usability */ // Elements where description is a sibling to the selected element $('form.webform-client-form .form-text,' + 'form.webform-client-form .form-select').each(function() { description = $(this).siblings('.description'); description.css('display', 'none'); tooltip_title = false; show_delay = 1; build_qtip(this, 'form', description.html()); }); // Elements where description is a sibling to the PARENT of the selected element $('form.webform-client-form .form-radios,' + 'form.webform-client-form .form-textarea').each(function() { description = $(this).parent().siblings('.description'); description.css('display', 'none'); tooltip_title = false; show_delay = 1; build_qtip(this, 'form', description.html()); }); } function build_qtip(el, type, desc) { if (type == 'form') { show_text = desc ? desc : ''; // By default, the description text is wrapped inside <p> // Since we are putting this in a tooltip we want to remove this // and any other tags that might possibly get set show_text = show_text.replace(/(<.*?>)/ig,""); set_my = 'left_center'; tip_position = 'left_center'; set_at = 'right_center'; show_event = 'focus'; hide_event = 'blur'; } else { // "Normal" tooltip show_text = $(el).children('.qtip-tooltip'); set_my = Drupal.settings.qtip.tooltip_position; set_at = Drupal.settings.qtip.target_position; show_event = Drupal.settings.qtip.show_event_type; hide_event = Drupal.settings.qtip.hide_event_type; } $(el).qtip({ content: { text: show_text, title: { text: tooltip_title } }, position: { my: set_my, // my = speech bubble position on tooltip at: set_at, // at = where on link text tooltip will appear adjust: { screen: true // Keeps tooltip within visible window } }, style: { classes: style_classes, tip: { corner: tip_position, // Position of speech bubble tip...false will not display tip border: solid_tip, // parseInt(Drupal.settings.qtip.border_width) width: parseInt(Drupal.settings.qtip.speech_bubble_size), height: parseInt(Drupal.settings.qtip.speech_bubble_size) } }, show: { event: show_event, solo: true, // Determines whether or not the tooltip will hide all others when the show.event is triggered on the show.target. delay: show_delay }, hide: { event: hide_event, fixed: true //When set to true, the tooltip will not hide if moused over, allowing the contents to be clicked and interacted with. } }); } } }; })(jQuery); ; /** * Cookie plugin 1.0 * * Copyright (c) 2006 Klaus Hartl (stilbuero.de) * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * */ jQuery.cookie=function(b,j,m){if(typeof j!="undefined"){m=m||{};if(j===null){j="";m.expires=-1}var e="";if(m.expires&&(typeof m.expires=="number"||m.expires.toUTCString)){var f;if(typeof m.expires=="number"){f=new Date();f.setTime(f.getTime()+(m.expires*24*60*60*1000))}else{f=m.expires}e="; expires="+f.toUTCString()}var l=m.path?"; path="+(m.path):"";var g=m.domain?"; domain="+(m.domain):"";var a=m.secure?"; secure":"";document.cookie=[b,"=",encodeURIComponent(j),e,l,g,a].join("")}else{var d=null;if(document.cookie&&document.cookie!=""){var k=document.cookie.split(";");for(var h=0;h<k.length;h++){var c=jQuery.trim(k[h]);if(c.substring(0,b.length+1)==(b+"=")){d=decodeURIComponent(c.substring(b.length+1));break}}}return d}}; ; /*! * jQuery Form Plugin * version: 2.52 (07-DEC-2010) * @requires jQuery v1.3.2 or later * * Examples and documentation at: http://malsup.com/jquery/form/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html */ ;(function(b){function q(){if(b.fn.ajaxSubmit.debug){var a="[jquery.form] "+Array.prototype.join.call(arguments,"");if(window.console&&window.console.log)window.console.log(a);else window.opera&&window.opera.postError&&window.opera.postError(a)}}b.fn.ajaxSubmit=function(a){function f(){function t(){var o=i.attr("target"),m=i.attr("action");l.setAttribute("target",u);l.getAttribute("method")!="POST"&&l.setAttribute("method","POST");l.getAttribute("action")!=e.url&&l.setAttribute("action",e.url);e.skipEncodingOverride|| i.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"});e.timeout&&setTimeout(function(){F=true;s()},e.timeout);var v=[];try{if(e.extraData)for(var w in e.extraData)v.push(b('<input type="hidden" name="'+w+'" value="'+e.extraData[w]+'" />').appendTo(l)[0]);r.appendTo("body");r.data("form-plugin-onload",s);l.submit()}finally{l.setAttribute("action",m);o?l.setAttribute("target",o):i.removeAttr("target");b(v).remove()}}function s(){if(!G){r.removeData("form-plugin-onload");var o=true; try{if(F)throw"timeout";p=x.contentWindow?x.contentWindow.document:x.contentDocument?x.contentDocument:x.document;var m=e.dataType=="xml"||p.XMLDocument||b.isXMLDoc(p);q("isXml="+m);if(!m&&window.opera&&(p.body==null||p.body.innerHTML==""))if(--K){q("requeing onLoad callback, DOM not available");setTimeout(s,250);return}G=true;j.responseText=p.documentElement?p.documentElement.innerHTML:null;j.responseXML=p.XMLDocument?p.XMLDocument:p;j.getResponseHeader=function(L){return{"content-type":e.dataType}[L]}; var v=/(json|script)/.test(e.dataType);if(v||e.textarea){var w=p.getElementsByTagName("textarea")[0];if(w)j.responseText=w.value;else if(v){var H=p.getElementsByTagName("pre")[0],I=p.getElementsByTagName("body")[0];if(H)j.responseText=H.textContent;else if(I)j.responseText=I.innerHTML}}else if(e.dataType=="xml"&&!j.responseXML&&j.responseText!=null)j.responseXML=C(j.responseText);J=b.httpData(j,e.dataType)}catch(D){q("error caught:",D);o=false;j.error=D;b.handleError(e,j,"error",D)}if(j.aborted){q("upload aborted"); o=false}if(o){e.success.call(e.context,J,"success",j);y&&b.event.trigger("ajaxSuccess",[j,e])}y&&b.event.trigger("ajaxComplete",[j,e]);y&&!--b.active&&b.event.trigger("ajaxStop");if(e.complete)e.complete.call(e.context,j,o?"success":"error");setTimeout(function(){r.removeData("form-plugin-onload");r.remove();j.responseXML=null},100)}}function C(o,m){if(window.ActiveXObject){m=new ActiveXObject("Microsoft.XMLDOM");m.async="false";m.loadXML(o)}else m=(new DOMParser).parseFromString(o,"text/xml");return m&& m.documentElement&&m.documentElement.tagName!="parsererror"?m:null}var l=i[0];if(b(":input[name=submit],:input[id=submit]",l).length)alert('Error: Form elements must not have name or id of "submit".');else{var e=b.extend(true,{},b.ajaxSettings,a);e.context=e.context||e;var u="jqFormIO"+(new Date).getTime(),E="_"+u;window[E]=function(){var o=r.data("form-plugin-onload");if(o){o();window[E]=undefined;try{delete window[E]}catch(m){}}};var r=b('<iframe id="'+u+'" name="'+u+'" src="'+e.iframeSrc+'" onload="window[\'_\'+this.id]()" />'), x=r[0];r.css({position:"absolute",top:"-1000px",left:"-1000px"});var j={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted=1;r.attr("src",e.iframeSrc)}},y=e.global;y&&!b.active++&&b.event.trigger("ajaxStart");y&&b.event.trigger("ajaxSend",[j,e]);if(e.beforeSend&&e.beforeSend.call(e.context,j,e)===false)e.global&&b.active--;else if(!j.aborted){var G=false, F=0,z=l.clk;if(z){var A=z.name;if(A&&!z.disabled){e.extraData=e.extraData||{};e.extraData[A]=z.value;if(z.type=="image"){e.extraData[A+".x"]=l.clk_x;e.extraData[A+".y"]=l.clk_y}}}e.forceSync?t():setTimeout(t,10);var J,p,K=50}}}if(!this.length){q("ajaxSubmit: skipping submit process - no element selected");return this}if(typeof a=="function")a={success:a};var d=this.attr("action");if(d=typeof d==="string"?b.trim(d):"")d=(d.match(/^([^#]+)/)||[])[1];d=d||window.location.href||"";a=b.extend(true,{url:d, type:this.attr("method")||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},a);d={};this.trigger("form-pre-serialize",[this,a,d]);if(d.veto){q("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(a.beforeSerialize&&a.beforeSerialize(this,a)===false){q("ajaxSubmit: submit aborted via beforeSerialize callback");return this}var c,h,g=this.formToArray(a.semantic);if(a.data){a.extraData=a.data;for(c in a.data)if(a.data[c]instanceof Array)for(var k in a.data[c])g.push({name:c, value:a.data[c][k]});else{h=a.data[c];h=b.isFunction(h)?h():h;g.push({name:c,value:h})}}if(a.beforeSubmit&&a.beforeSubmit(g,this,a)===false){q("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[g,this,a,d]);if(d.veto){q("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}c=b.param(g);if(a.type.toUpperCase()=="GET"){a.url+=(a.url.indexOf("?")>=0?"&":"?")+c;a.data=null}else a.data=c;var i=this,n=[];a.resetForm&&n.push(function(){i.resetForm()}); a.clearForm&&n.push(function(){i.clearForm()});if(!a.dataType&&a.target){var B=a.success||function(){};n.push(function(t){var s=a.replaceTarget?"replaceWith":"html";b(a.target)[s](t).each(B,arguments)})}else a.success&&n.push(a.success);a.success=function(t,s,C){for(var l=a.context||a,e=0,u=n.length;e<u;e++)n[e].apply(l,[t,s,C||i,i])};c=b("input:file",this).length>0;k=i.attr("enctype")=="multipart/form-data"||i.attr("encoding")=="multipart/form-data";if(a.iframe!==false&&(c||a.iframe||k))a.closeKeepAlive? b.get(a.closeKeepAlive,f):f();else b.ajax(a);this.trigger("form-submit-notify",[this,a]);return this};b.fn.ajaxForm=function(a){if(this.length===0){var f={s:this.selector,c:this.context};if(!b.isReady&&f.s){q("DOM not ready, queuing ajaxForm");b(function(){b(f.s,f.c).ajaxForm(a)});return this}q("terminating; zero elements found by selector"+(b.isReady?"":" (DOM not ready)"));return this}return this.ajaxFormUnbind().bind("submit.form-plugin",function(d){if(!d.isDefaultPrevented()){d.preventDefault(); b(this).ajaxSubmit(a)}}).bind("click.form-plugin",function(d){var c=d.target,h=b(c);if(!h.is(":submit,input:image")){c=h.closest(":submit");if(c.length==0)return;c=c[0]}var g=this;g.clk=c;if(c.type=="image")if(d.offsetX!=undefined){g.clk_x=d.offsetX;g.clk_y=d.offsetY}else if(typeof b.fn.offset=="function"){h=h.offset();g.clk_x=d.pageX-h.left;g.clk_y=d.pageY-h.top}else{g.clk_x=d.pageX-c.offsetLeft;g.clk_y=d.pageY-c.offsetTop}setTimeout(function(){g.clk=g.clk_x=g.clk_y=null},100)})};b.fn.ajaxFormUnbind= function(){return this.unbind("submit.form-plugin click.form-plugin")};b.fn.formToArray=function(a){var f=[];if(this.length===0)return f;var d=this[0],c=a?d.getElementsByTagName("*"):d.elements;if(!c)return f;var h,g,k,i,n,B;h=0;for(n=c.length;h<n;h++){g=c[h];if(k=g.name)if(a&&d.clk&&g.type=="image"){if(!g.disabled&&d.clk==g){f.push({name:k,value:b(g).val()});f.push({name:k+".x",value:d.clk_x},{name:k+".y",value:d.clk_y})}}else if((i=b.fieldValue(g,true))&&i.constructor==Array){g=0;for(B=i.length;g< B;g++)f.push({name:k,value:i[g]})}else i!==null&&typeof i!="undefined"&&f.push({name:k,value:i})}if(!a&&d.clk){a=b(d.clk);c=a[0];if((k=c.name)&&!c.disabled&&c.type=="image"){f.push({name:k,value:a.val()});f.push({name:k+".x",value:d.clk_x},{name:k+".y",value:d.clk_y})}}return f};b.fn.formSerialize=function(a){return b.param(this.formToArray(a))};b.fn.fieldSerialize=function(a){var f=[];this.each(function(){var d=this.name;if(d){var c=b.fieldValue(this,a);if(c&&c.constructor==Array)for(var h=0,g=c.length;h< g;h++)f.push({name:d,value:c[h]});else c!==null&&typeof c!="undefined"&&f.push({name:this.name,value:c})}});return b.param(f)};b.fn.fieldValue=function(a){for(var f=[],d=0,c=this.length;d<c;d++){var h=b.fieldValue(this[d],a);h===null||typeof h=="undefined"||h.constructor==Array&&!h.length||(h.constructor==Array?b.merge(f,h):f.push(h))}return f};b.fieldValue=function(a,f){var d=a.name,c=a.type,h=a.tagName.toLowerCase();if(f===undefined)f=true;if(f&&(!d||a.disabled||c=="reset"||c=="button"||(c=="checkbox"|| c=="radio")&&!a.checked||(c=="submit"||c=="image")&&a.form&&a.form.clk!=a||h=="select"&&a.selectedIndex==-1))return null;if(h=="select"){var g=a.selectedIndex;if(g<0)return null;d=[];h=a.options;var k=(c=c=="select-one")?g+1:h.length;for(g=c?g:0;g<k;g++){var i=h[g];if(i.selected){var n=i.value;n||(n=i.attributes&&i.attributes.value&&!i.attributes.value.specified?i.text:i.value);if(c)return n;d.push(n)}}return d}return b(a).val()};b.fn.clearForm=function(){return this.each(function(){b("input,select,textarea", this).clearFields()})};b.fn.clearFields=b.fn.clearInputs=function(){return this.each(function(){var a=this.type,f=this.tagName.toLowerCase();if(a=="text"||a=="password"||f=="textarea")this.value="";else if(a=="checkbox"||a=="radio")this.checked=false;else if(f=="select")this.selectedIndex=-1})};b.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=="function"||typeof this.reset=="object"&&!this.reset.nodeType)this.reset()})};b.fn.enable=function(a){if(a===undefined)a=true;return this.each(function(){this.disabled= !a})};b.fn.selected=function(a){if(a===undefined)a=true;return this.each(function(){var f=this.type;if(f=="checkbox"||f=="radio")this.checked=a;else if(this.tagName.toLowerCase()=="option"){f=b(this).parent("select");a&&f[0]&&f[0].type=="select-one"&&f.find("option").selected(false);this.selected=a}})}})(jQuery);; /* * jQuery UI Tabs 1.8.7 * * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Tabs * * Depends: * jquery.ui.core.js * jquery.ui.widget.js */ (function(d,p){function u(){return++v}function w(){return++x}var v=0,x=0;d.widget("ui.tabs",{options:{add:null,ajaxOptions:null,cache:false,cookie:null,collapsible:false,disable:null,disabled:[],enable:null,event:"click",fx:null,idPrefix:"ui-tabs-",load:null,panelTemplate:"<div></div>",remove:null,select:null,show:null,spinner:"<em>Loading…</em>",tabTemplate:"<li><a href='#{href}'><span>#{label}</span></a></li>"},_create:function(){this._tabify(true)},_setOption:function(b,e){if(b=="selected")this.options.collapsible&& e==this.options.selected||this.select(e);else{this.options[b]=e;this._tabify()}},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+u()},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+w());return d.cookie.apply(null,[b].concat(d.makeArray(arguments)))},_ui:function(b,e){return{tab:b,panel:e,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b= d(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(b){function e(g,f){g.css("display","");!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}var a=this,c=this.options,h=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=d(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);this.anchors.each(function(g,f){var i=d(f).attr("href"),l=i.split("#")[0],q;if(l&&(l===location.toString().split("#")[0]|| (q=d("base")[0])&&l===q.href)){i=f.hash;f.href=i}if(h.test(i))a.panels=a.panels.add(a.element.find(a._sanitizeSelector(i)));else if(i&&i!=="#"){d.data(f,"href.tabs",i);d.data(f,"load.tabs",i.replace(/#.*$/,""));i=a._tabId(f);f.href="#"+i;f=a.element.find("#"+i);if(!f.length){f=d(c.panelTemplate).attr("id",i).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else c.disabled.push(g)});if(b){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"); this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(c.selected===p){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){c.selected=g;return false}});if(typeof c.selected!=="number"&&c.cookie)c.selected=parseInt(a._cookie(),10);if(typeof c.selected!=="number"&&this.lis.filter(".ui-tabs-selected").length)c.selected= this.lis.index(this.lis.filter(".ui-tabs-selected"));c.selected=c.selected||(this.lis.length?0:-1)}else if(c.selected===null)c.selected=-1;c.selected=c.selected>=0&&this.anchors[c.selected]||c.selected<0?c.selected:0;c.disabled=d.unique(c.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(c.selected,c.disabled)!=-1&&c.disabled.splice(d.inArray(c.selected,c.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active"); if(c.selected>=0&&this.anchors.length){a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash)).removeClass("ui-tabs-hide");this.lis.eq(c.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[c.selected],a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash))))});this.load(c.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else c.selected=this.lis.index(this.lis.filter(".ui-tabs-selected")); this.element[c.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");c.cookie&&this._cookie(c.selected,c.cookie);b=0;for(var j;j=this.lis[b];b++)d(j)[d.inArray(b,c.disabled)!=-1&&!d(j).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");c.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(c.event!=="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+ g)};this.lis.bind("mouseover.tabs",function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(c.fx)if(d.isArray(c.fx)){m=c.fx[0];o=c.fx[1]}else m=o=c.fx;var r=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal", function(){e(f,o);a._trigger("show",null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},s=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")}; this.anchors.bind(c.event+".tabs",function(){var g=this,f=d(g).closest("li"),i=a.panels.filter(":not(.ui-tabs-hide)"),l=a.element.find(a._sanitizeSelector(g.hash));if(f.hasClass("ui-tabs-selected")&&!c.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a.panels.filter(":animated").length||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}c.selected=a.anchors.index(this);a.abort();if(c.collapsible)if(f.hasClass("ui-tabs-selected")){c.selected= -1;c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){s(g,i)}).dequeue("tabs");this.blur();return false}else if(!i.length){c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this));this.blur();return false}c.cookie&&a._cookie(c.selected,c.cookie);if(l.length){i.length&&a.element.queue("tabs",function(){s(g,i)});a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier."; d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(b){if(typeof b=="string")b=this.anchors.index(this.anchors.filter("[href$="+b+"]"));return b},destroy:function(){var b=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e= d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(c,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});b.cookie&&this._cookie(null,b.cookie);return this},add:function(b, e,a){if(a===p)a=this.anchors.length;var c=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,b).replace(/#\{label\}/g,e));b=!b.indexOf("#")?b.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var j=c.element.find("#"+b);j.length||(j=d(h.panelTemplate).attr("id",b).data("destroy.tabs",true));j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);j.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]); j.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");j.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){c._trigger("show",null,c._ui(c.anchors[0],c.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(b){b=this._getIndex(b);var e=this.options,a=this.lis.eq(b).remove(),c=this.panels.eq(b).remove(); if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(b+(b+1<this.anchors.length?1:-1));e.disabled=d.map(d.grep(e.disabled,function(h){return h!=b}),function(h){return h>=b?--h:h});this._tabify();this._trigger("remove",null,this._ui(a.find("a")[0],c[0]));return this},enable:function(b){b=this._getIndex(b);var e=this.options;if(d.inArray(b,e.disabled)!=-1){this.lis.eq(b).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=b});this._trigger("enable",null, this._ui(this.anchors[b],this.panels[b]));return this}},disable:function(b){b=this._getIndex(b);var e=this.options;if(b!=e.selected){this.lis.eq(b).addClass("ui-state-disabled");e.disabled.push(b);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[b],this.panels[b]))}return this},select:function(b){b=this._getIndex(b);if(b==-1)if(this.options.collapsible&&this.options.selected!=-1)b=this.options.selected;else return this;this.anchors.eq(b).trigger(this.options.event+".tabs");return this}, load:function(b){b=this._getIndex(b);var e=this,a=this.options,c=this.anchors.eq(b)[0],h=d.data(c,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(c,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(b).addClass("ui-state-processing");if(a.spinner){var j=d("span",c);j.data("label.tabs",j.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){e.element.find(e._sanitizeSelector(c.hash)).html(k);e._cleanup();a.cache&&d.data(c, "cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.error(k,n,b,c)}catch(m){}}}));e.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this}, url:function(b,e){this.anchors.eq(b).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.7"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(b,e){var a=this,c=this.options,h=a._rotate||(a._rotate=function(j){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=c.selected;a.select(++k<a.anchors.length?k:0)},b);j&&j.stopPropagation()});e=a._unrotate||(a._unrotate=!e?function(j){j.clientX&& a.rotate(null)}:function(){t=c.selected;h()});if(b){this.element.bind("tabsshow",h);this.anchors.bind(c.event+".tabs",e);h()}else{clearTimeout(a.rotation);this.element.unbind("tabsshow",h);this.anchors.unbind(c.event+".tabs",e);delete this._rotate;delete this._unrotate}return this}})})(jQuery); ; (function ($) { 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 Drupal.settings.viewsSlideshowControls[options.slideshowID].top.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowControls[options.slideshowID].top.type].play == 'function') { Drupal[Drupal.settings.viewsSlideshowControls[options.slideshowID].top.type].play(options); } } catch(err) { // Don't need to do anything on error. } try { if (typeof Drupal.settings.viewsSlideshowControls[options.slideshowID].bottom.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowControls[options.slideshowID].bottom.type].play == 'function') { Drupal[Drupal.settings.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 Drupal.settings.viewsSlideshowControls[options.slideshowID].top.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowControls[options.slideshowID].top.type].pause == 'function') { Drupal[Drupal.settings.viewsSlideshowControls[options.slideshowID].top.type].pause(options); } } catch(err) { // Don't need to do anything on error. } try { if (typeof Drupal.settings.viewsSlideshowControls[options.slideshowID].bottom.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowControls[options.slideshowID].bottom.type].pause == 'function') { Drupal[Drupal.settings.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 (Drupal.settings.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 Drupal.settings.viewsSlideshowPager != "undefined" && typeof Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].transitionBegin == 'function') { Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].transitionBegin(options); } } catch(err) { // Don't need to do anything on error. } try { if (typeof Drupal.settings.viewsSlideshowPager != "undefined" && typeof Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type].transitionBegin == 'function') { Drupal[Drupal.settings.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 Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].goToSlide == 'function') { Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].goToSlide(options); } } catch(err) { // Don't need to do anything on error. } try { if (typeof Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type].goToSlide == 'function') { Drupal[Drupal.settings.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 Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].previousSlide == 'function') { Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].previousSlide(options); } } catch(err) { // Don't need to do anything on error. } try { if (typeof Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type].previousSlide == 'function') { Drupal[Drupal.settings.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 Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].nextSlide == 'function') { Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].top.type].nextSlide(options); } } catch(err) { // Don't need to do anything on error. } try { if (typeof Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type != "undefined" && typeof Drupal[Drupal.settings.viewsSlideshowPager[options.slideshowID].bottom.type].nextSlide == 'function') { Drupal[Drupal.settings.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 (Drupal.settings.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 Drupal.settings.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 Drupal.settings.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 Drupal.settings.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 Drupal.settings.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') { Drupal.settings.viewsSlideshow[options.slideshowID].paused = 1; // If the calling method is forcing a pause then mark it as such. if (options.force) { Drupal.settings.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 (!Drupal.settings.viewsSlideshow[options.slideshowID].pausedForce || options.force) { Drupal.settings.viewsSlideshow[options.slideshowID].paused = 0; Drupal.settings.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 = Drupal.settings.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); ; (function ($) { /** * Provides Ajax page updating via jQuery $.ajax (Asynchronous JavaScript and XML). * * Ajax is a method of making a request via JavaScript while viewing an HTML * page. The request returns an array of commands encoded in JSON, which is * then executed to make any changes that are necessary to the page. * * Drupal uses this file to enhance form elements with #ajax['path'] and * #ajax['wrapper'] properties. If set, this file will automatically be included * to provide Ajax capabilities. */ Drupal.ajax = Drupal.ajax || {}; Drupal.settings.urlIsAjaxTrusted = Drupal.settings.urlIsAjaxTrusted || {}; /** * Attaches the Ajax behavior to each Ajax form element. */ Drupal.behaviors.AJAX = { attach: function (context, settings) { // Load all Ajax behaviors specified in the settings. for (var base in settings.ajax) { if (!$('#' + base + '.ajax-processed').length) { var element_settings = settings.ajax[base]; if (typeof element_settings.selector == 'undefined') { element_settings.selector = '#' + base; } $(element_settings.selector).each(function () { element_settings.element = this; Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); }); $('#' + base).addClass('ajax-processed'); } } // Bind Ajax behaviors to all items showing the class. $('.use-ajax:not(.ajax-processed)').addClass('ajax-processed').each(function () { var element_settings = {}; // Clicked links look better with the throbber than the progress bar. element_settings.progress = { 'type': 'throbber' }; // For anchor tags, these will go to the target of the anchor rather // than the usual location. if ($(this).attr('href')) { element_settings.url = $(this).attr('href'); element_settings.event = 'click'; } var base = $(this).attr('id'); Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); }); // This class means to submit the form to the action using Ajax. $('.use-ajax-submit:not(.ajax-processed)').addClass('ajax-processed').each(function () { var element_settings = {}; // Ajax submits specified in this manner automatically submit to the // normal form action. element_settings.url = $(this.form).attr('action'); // Form submit button clicks need to tell the form what was clicked so // it gets passed in the POST request. element_settings.setClick = true; // Form buttons use the 'click' event rather than mousedown. element_settings.event = 'click'; // Clicked form buttons look better with the throbber than the progress bar. element_settings.progress = { 'type': 'throbber' }; var base = $(this).attr('id'); Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); }); } }; /** * Ajax object. * * All Ajax objects on a page are accessible through the global Drupal.ajax * object and are keyed by the submit button's ID. You can access them from * your module's JavaScript file to override properties or functions. * * For example, if your Ajax enabled button has the ID 'edit-submit', you can * redefine the function that is called to insert the new content like this * (inside a Drupal.behaviors attach block): * @code * Drupal.behaviors.myCustomAJAXStuff = { * attach: function (context, settings) { * Drupal.ajax['edit-submit'].commands.insert = function (ajax, response, status) { * new_content = $(response.data); * $('#my-wrapper').append(new_content); * alert('New content was appended to #my-wrapper'); * } * } * }; * @endcode */ Drupal.ajax = function (base, element, element_settings) { var defaults = { url: 'system/ajax', event: 'mousedown', keypress: true, selector: '#' + base, effect: 'none', speed: 'none', method: 'replaceWith', progress: { type: 'throbber', message: Drupal.t('Please wait...') }, submit: { 'js': true } }; $.extend(this, defaults, element_settings); this.element = element; this.element_settings = element_settings; // Replacing 'nojs' with 'ajax' in the URL allows for an easy method to let // the server detect when it needs to degrade gracefully. // There are five scenarios to check for: // 1. /nojs/ // 2. /nojs$ - The end of a URL string. // 3. /nojs? - Followed by a query (with clean URLs enabled). // E.g.: path/nojs?destination=foobar // 4. /nojs& - Followed by a query (without clean URLs enabled). // E.g.: ?q=path/nojs&destination=foobar // 5. /nojs# - Followed by a fragment. // E.g.: path/nojs#myfragment this.url = element_settings.url.replace(/\/nojs(\/|$|\?|&|#)/g, '/ajax$1'); // If the 'nojs' version of the URL is trusted, also trust the 'ajax' version. if (Drupal.settings.urlIsAjaxTrusted[element_settings.url]) { Drupal.settings.urlIsAjaxTrusted[this.url] = true; } this.wrapper = '#' + element_settings.wrapper; // If there isn't a form, jQuery.ajax() will be used instead, allowing us to // bind Ajax to links as well. if (this.element.form) { this.form = $(this.element.form); } // Set the options for the ajaxSubmit function. // The 'this' variable will not persist inside of the options object. var ajax = this; ajax.options = { url: ajax.url, data: ajax.submit, beforeSerialize: function (element_settings, options) { return ajax.beforeSerialize(element_settings, options); }, beforeSubmit: function (form_values, element_settings, options) { ajax.ajaxing = true; return ajax.beforeSubmit(form_values, element_settings, options); }, beforeSend: function (xmlhttprequest, options) { ajax.ajaxing = true; return ajax.beforeSend(xmlhttprequest, options); }, success: function (response, status, xmlhttprequest) { // Sanity check for browser support (object expected). // When using iFrame uploads, responses must be returned as a string. if (typeof response == 'string') { response = $.parseJSON(response); } // Prior to invoking the response's commands, verify that they can be // trusted by checking for a response header. See // ajax_set_verification_header() for details. // - Empty responses are harmless so can bypass verification. This avoids // an alert message for server-generated no-op responses that skip Ajax // rendering. // - Ajax objects with trusted URLs (e.g., ones defined server-side via // #ajax) can bypass header verification. This is especially useful for // Ajax with multipart forms. Because IFRAME transport is used, the // response headers cannot be accessed for verification. if (response !== null && !Drupal.settings.urlIsAjaxTrusted[ajax.url]) { if (xmlhttprequest.getResponseHeader('X-Drupal-Ajax-Token') !== '1') { var customMessage = Drupal.t("The response failed verification so will not be processed."); return ajax.error(xmlhttprequest, ajax.url, customMessage); } } return ajax.success(response, status); }, complete: function (xmlhttprequest, status) { ajax.ajaxing = false; if (status == 'error' || status == 'parsererror') { return ajax.error(xmlhttprequest, ajax.url); } }, dataType: 'json', type: 'POST' }; // Bind the ajaxSubmit function to the element event. $(ajax.element).bind(element_settings.event, function (event) { if (!Drupal.settings.urlIsAjaxTrusted[ajax.url] && !Drupal.urlIsLocal(ajax.url)) { throw new Error(Drupal.t('The callback URL is not local and not trusted: !url', {'!url': ajax.url})); } return ajax.eventResponse(this, event); }); // If necessary, enable keyboard submission so that Ajax behaviors // can be triggered through keyboard input as well as e.g. a mousedown // action. if (element_settings.keypress) { $(ajax.element).keypress(function (event) { return ajax.keypressResponse(this, event); }); } // If necessary, prevent the browser default action of an additional event. // For example, prevent the browser default action of a click, even if the // AJAX behavior binds to mousedown. if (element_settings.prevent) { $(ajax.element).bind(element_settings.prevent, false); } }; /** * Handle a key press. * * The Ajax object will, if instructed, bind to a key press response. This * will test to see if the key press is valid to trigger this event and * if it is, trigger it for us and prevent other keypresses from triggering. * In this case we're handling RETURN and SPACEBAR keypresses (event codes 13 * and 32. RETURN is often used to submit a form when in a textfield, and * SPACE is often used to activate an element without submitting. */ Drupal.ajax.prototype.keypressResponse = function (element, event) { // Create a synonym for this to reduce code confusion. var ajax = this; // Detect enter key and space bar and allow the standard response for them, // except for form elements of type 'text' and 'textarea', where the // spacebar activation causes inappropriate activation if #ajax['keypress'] is // TRUE. On a text-type widget a space should always be a space. if (event.which == 13 || (event.which == 32 && element.type != 'text' && element.type != 'textarea')) { $(ajax.element_settings.element).trigger(ajax.element_settings.event); return false; } }; /** * Handle an event that triggers an Ajax response. * * When an event that triggers an Ajax response happens, this method will * perform the actual Ajax call. It is bound to the event using * bind() in the constructor, and it uses the options specified on the * ajax object. */ Drupal.ajax.prototype.eventResponse = function (element, event) { // Create a synonym for this to reduce code confusion. var ajax = this; // Do not perform another ajax command if one is already in progress. if (ajax.ajaxing) { return false; } try { if (ajax.form) { // If setClick is set, we must set this to ensure that the button's // value is passed. if (ajax.setClick) { // Mark the clicked button. 'form.clk' is a special variable for // ajaxSubmit that tells the system which element got clicked to // trigger the submit. Without it there would be no 'op' or // equivalent. element.form.clk = element; } ajax.form.ajaxSubmit(ajax.options); } else { ajax.beforeSerialize(ajax.element, ajax.options); $.ajax(ajax.options); } } catch (e) { // Unset the ajax.ajaxing flag here because it won't be unset during // the complete response. ajax.ajaxing = false; alert("An error occurred while attempting to process " + ajax.options.url + ": " + e.message); } // For radio/checkbox, allow the default event. On IE, this means letting // it actually check the box. if (typeof element.type != 'undefined' && (element.type == 'checkbox' || element.type == 'radio')) { return true; } else { return false; } }; /** * Handler for the form serialization. * * Runs before the beforeSend() handler (see below), and unlike that one, runs * before field data is collected. */ Drupal.ajax.prototype.beforeSerialize = function (element, options) { // Allow detaching behaviors to update field values before collecting them. // This is only needed when field values are added to the POST data, so only // when there is a form such that this.form.ajaxSubmit() is used instead of // $.ajax(). When there is no form and $.ajax() is used, beforeSerialize() // isn't called, but don't rely on that: explicitly check this.form. if (this.form) { var settings = this.settings || Drupal.settings; Drupal.detachBehaviors(this.form, settings, 'serialize'); } // Prevent duplicate HTML ids in the returned markup. // @see drupal_html_id() options.data['ajax_html_ids[]'] = []; $('[id]').each(function () { options.data['ajax_html_ids[]'].push(this.id); }); // Allow Drupal to return new JavaScript and CSS files to load without // returning the ones already loaded. // @see ajax_base_page_theme() // @see drupal_get_css() // @see drupal_get_js() options.data['ajax_page_state[theme]'] = Drupal.settings.ajaxPageState.theme; options.data['ajax_page_state[theme_token]'] = Drupal.settings.ajaxPageState.theme_token; for (var key in Drupal.settings.ajaxPageState.css) { options.data['ajax_page_state[css][' + key + ']'] = 1; } for (var key in Drupal.settings.ajaxPageState.js) { options.data['ajax_page_state[js][' + key + ']'] = 1; } }; /** * Modify form values prior to form submission. */ Drupal.ajax.prototype.beforeSubmit = function (form_values, element, options) { // This function is left empty to make it simple to override for modules // that wish to add functionality here. }; /** * Prepare the Ajax request before it is sent. */ Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) { // For forms without file inputs, the jQuery Form plugin serializes the form // values, and then calls jQuery's $.ajax() function, which invokes this // handler. In this circumstance, options.extraData is never used. For forms // with file inputs, the jQuery Form plugin uses the browser's normal form // submission mechanism, but captures the response in a hidden IFRAME. In this // circumstance, it calls this handler first, and then appends hidden fields // to the form to submit the values in options.extraData. There is no simple // way to know which submission mechanism will be used, so we add to extraData // regardless, and allow it to be ignored in the former case. if (this.form) { options.extraData = options.extraData || {}; // Let the server know when the IFRAME submission mechanism is used. The // server can use this information to wrap the JSON response in a TEXTAREA, // as per http://jquery.malsup.com/form/#file-upload. options.extraData.ajax_iframe_upload = '1'; // The triggering element is about to be disabled (see below), but if it // contains a value (e.g., a checkbox, textfield, select, etc.), ensure that // value is included in the submission. As per above, submissions that use // $.ajax() are already serialized prior to the element being disabled, so // this is only needed for IFRAME submissions. var v = $.fieldValue(this.element); if (v !== null) { options.extraData[this.element.name] = Drupal.checkPlain(v); } } // Disable the element that received the change to prevent user interface // interaction while the Ajax request is in progress. ajax.ajaxing prevents // the element from triggering a new request, but does not prevent the user // from changing its value. $(this.element).addClass('progress-disabled').attr('disabled', true); // Insert progressbar or throbber. if (this.progress.type == 'bar') { var progressBar = new Drupal.progressBar('ajax-progress-' + this.element.id, eval(this.progress.update_callback), this.progress.method, eval(this.progress.error_callback)); if (this.progress.message) { progressBar.setProgress(-1, this.progress.message); } if (this.progress.url) { progressBar.startMonitoring(this.progress.url, this.progress.interval || 1500); } this.progress.element = $(progressBar.element).addClass('ajax-progress ajax-progress-bar'); this.progress.object = progressBar; $(this.element).after(this.progress.element); } else if (this.progress.type == 'throbber') { this.progress.element = $('<div class="ajax-progress ajax-progress-throbber"><div class="throbber"> </div></div>'); if (this.progress.message) { $('.throbber', this.progress.element).after('<div class="message">' + this.progress.message + '</div>'); } $(this.element).after(this.progress.element); } }; /** * Handler for the form redirection completion. */ Drupal.ajax.prototype.success = function (response, status) { // Remove the progress element. if (this.progress.element) { $(this.progress.element).remove(); } if (this.progress.object) { this.progress.object.stopMonitoring(); } $(this.element).removeClass('progress-disabled').removeAttr('disabled'); Drupal.freezeHeight(); for (var i in response) { if (response.hasOwnProperty(i) && response[i]['command'] && this.commands[response[i]['command']]) { this.commands[response[i]['command']](this, response[i], status); } } // Reattach behaviors, if they were detached in beforeSerialize(). The // attachBehaviors() called on the new content from processing the response // commands is not sufficient, because behaviors from the entire form need // to be reattached. if (this.form) { var settings = this.settings || Drupal.settings; Drupal.attachBehaviors(this.form, settings); } Drupal.unfreezeHeight(); // Remove any response-specific settings so they don't get used on the next // call by mistake. this.settings = null; }; /** * Build an effect object which tells us how to apply the effect when adding new HTML. */ Drupal.ajax.prototype.getEffect = function (response) { var type = response.effect || this.effect; var speed = response.speed || this.speed; var effect = {}; if (type == 'none') { effect.showEffect = 'show'; effect.hideEffect = 'hide'; effect.showSpeed = ''; } else if (type == 'fade') { effect.showEffect = 'fadeIn'; effect.hideEffect = 'fadeOut'; effect.showSpeed = speed; } else { effect.showEffect = type + 'Toggle'; effect.hideEffect = type + 'Toggle'; effect.showSpeed = speed; } return effect; }; /** * Handler for the form redirection error. */ Drupal.ajax.prototype.error = function (xmlhttprequest, uri, customMessage) { Drupal.displayAjaxError(Drupal.ajaxError(xmlhttprequest, uri, customMessage)); // Remove the progress element. if (this.progress.element) { $(this.progress.element).remove(); } if (this.progress.object) { this.progress.object.stopMonitoring(); } // Undo hide. $(this.wrapper).show(); // Re-enable the element. $(this.element).removeClass('progress-disabled').removeAttr('disabled'); // Reattach behaviors, if they were detached in beforeSerialize(). if (this.form) { var settings = this.settings || Drupal.settings; Drupal.attachBehaviors(this.form, settings); } }; /** * Provide a series of commands that the server can request the client perform. */ Drupal.ajax.prototype.commands = { /** * Command to insert new content into the DOM. */ insert: function (ajax, response, status) { // Get information from the response. If it is not there, default to // our presets. var wrapper = response.selector ? $(response.selector) : $(ajax.wrapper); var method = response.method || ajax.method; var effect = ajax.getEffect(response); // We don't know what response.data contains: it might be a string of text // without HTML, so don't rely on jQuery correctly iterpreting // $(response.data) as new HTML rather than a CSS selector. Also, if // response.data contains top-level text nodes, they get lost with either // $(response.data) or $('<div></div>').replaceWith(response.data). var new_content_wrapped = $('<div></div>').html(response.data); var new_content = new_content_wrapped.contents(); // For legacy reasons, the effects processing code assumes that new_content // consists of a single top-level element. Also, it has not been // sufficiently tested whether attachBehaviors() can be successfully called // with a context object that includes top-level text nodes. However, to // give developers full control of the HTML appearing in the page, and to // enable Ajax content to be inserted in places where DIV elements are not // allowed (e.g., within TABLE, TR, and SPAN parents), we check if the new // content satisfies the requirement of a single top-level element, and // only use the container DIV created above when it doesn't. For more // information, please see http://drupal.org/node/736066. if (new_content.length != 1 || new_content.get(0).nodeType != 1) { new_content = new_content_wrapped; } // If removing content from the wrapper, detach behaviors first. switch (method) { case 'html': case 'replaceWith': case 'replaceAll': case 'empty': case 'remove': var settings = response.settings || ajax.settings || Drupal.settings; Drupal.detachBehaviors(wrapper, settings); } // Add the new content to the page. wrapper[method](new_content); // Immediately hide the new content if we're using any effects. if (effect.showEffect != 'show') { new_content.hide(); } // Determine which effect to use and what content will receive the // effect, then show the new content. if ($('.ajax-new-content', new_content).length > 0) { $('.ajax-new-content', new_content).hide(); new_content.show(); $('.ajax-new-content', new_content)[effect.showEffect](effect.showSpeed); } else if (effect.showEffect != 'show') { new_content[effect.showEffect](effect.showSpeed); } // Attach all JavaScript behaviors to the new content, if it was successfully // added to the page, this if statement allows #ajax['wrapper'] to be // optional. if (new_content.parents('html').length > 0) { // Apply any settings from the returned JSON if available. var settings = response.settings || ajax.settings || Drupal.settings; Drupal.attachBehaviors(new_content, settings); } }, /** * Command to remove a chunk from the page. */ remove: function (ajax, response, status) { var settings = response.settings || ajax.settings || Drupal.settings; Drupal.detachBehaviors($(response.selector), settings); $(response.selector).remove(); }, /** * Command to mark a chunk changed. */ changed: function (ajax, response, status) { if (!$(response.selector).hasClass('ajax-changed')) { $(response.selector).addClass('ajax-changed'); if (response.asterisk) { $(response.selector).find(response.asterisk).append(' <span class="ajax-changed">*</span> '); } } }, /** * Command to provide an alert. */ alert: function (ajax, response, status) { alert(response.text, response.title); }, /** * Command to provide the jQuery css() function. */ css: function (ajax, response, status) { $(response.selector).css(response.argument); }, /** * Command to set the settings that will be used for other commands in this response. */ settings: function (ajax, response, status) { if (response.merge) { $.extend(true, Drupal.settings, response.settings); } else { ajax.settings = response.settings; } }, /** * Command to attach data using jQuery's data API. */ data: function (ajax, response, status) { $(response.selector).data(response.name, response.value); }, /** * Command to apply a jQuery method. */ invoke: function (ajax, response, status) { var $element = $(response.selector); $element[response.method].apply($element, response.arguments); }, /** * Command to restripe a table. */ restripe: function (ajax, response, status) { // :even and :odd are reversed because jQuery counts from 0 and // we count from 1, so we're out of sync. // Match immediate children of the parent element to allow nesting. $('> tbody > tr:visible, > tr:visible', $(response.selector)) .removeClass('odd even') .filter(':even').addClass('odd').end() .filter(':odd').addClass('even'); }, /** * Command to add css. * * Uses the proprietary addImport method if available as browsers which * support that method ignore @import statements in dynamically added * stylesheets. */ add_css: function (ajax, response, status) { // Add the styles in the normal way. $('head').prepend(response.data); // Add imports in the styles using the addImport method if available. var match, importMatch = /^@import url\("(.*)"\);$/igm; if (document.styleSheets[0].addImport && importMatch.test(response.data)) { importMatch.lastIndex = 0; while (match = importMatch.exec(response.data)) { document.styleSheets[0].addImport(match[1]); } } }, /** * Command to update a form's build ID. */ updateBuildId: function(ajax, response, status) { $('input[name="form_build_id"][value="' + response['old'] + '"]').val(response['new']); } }; })(jQuery); ;