PageRenderTime 63ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/default/files/js/js_DJsKxKQkhBY7CuB_OWSh_nucsxwQL7gCA1kfdpD5hrI.js

https://gitlab.com/Blueprint-Marketing/moose
JavaScript | 1120 lines | 529 code | 111 blank | 480 comment | 154 complexity | decba1c603378dce0a85f4357b456358 MD5 | raw file
  1. /*!
  2. * jQuery UI 1.8.7
  3. *
  4. * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
  5. * Dual licensed under the MIT or GPL Version 2 licenses.
  6. * http://jquery.org/license
  7. *
  8. * http://docs.jquery.com/UI
  9. */
  10. (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,
  11. 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,
  12. "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");
  13. 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,
  14. "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,
  15. 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")}});
  16. 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]]&&
  17. 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);
  18. ;
  19. /*
  20. * jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010
  21. * http://benalman.com/projects/jquery-bbq-plugin/
  22. *
  23. * Copyright (c) 2010 "Cowboy" Ben Alman
  24. * Dual licensed under the MIT and GPL licenses.
  25. * http://benalman.com/about/license/
  26. */
  27. (function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M<N?O[P]||(R[M+1]&&isNaN(R[M+1])?{}:[]):J}}else{if($.isArray(H[P])){H[P].push(J)}else{if(H[P]!==i){H[P]=[H[P],J]}else{H[P]=J}}}}else{if(P){H[P]=F?i:""}}});return H};function z(H,F,G){if(F===i||typeof F==="boolean"){G=F;F=a[H?D:A]()}else{F=E(F)?F.replace(H?w:x,""):F}return l(F,G)}l[A]=B(z,0);l[D]=v=B(z,1);$[y]||($[y]=function(F){return $.extend(C,F)})({a:k,base:k,iframe:t,img:t,input:t,form:"action",link:k,script:t});j=$[y];function s(I,G,H,F){if(!E(H)&&typeof H!=="object"){F=H;H=G;G=i}return this.each(function(){var L=$(this),J=G||j()[(this.nodeName||"").toLowerCase()]||"",K=J&&L.attr(J)||"";L.attr(J,a[I](K,H,F))})}$.fn[A]=B(s,A);$.fn[D]=B(s,D);b.pushState=q=function(I,F){if(E(I)&&/^#/.test(I)&&F===i){F=2}var H=I!==i,G=c(p[g][k],H?I:{},H?F:2);p[g][k]=G+(/#/.test(G)?"":"#")};b.getState=u=function(F,G){return F===i||typeof F==="boolean"?v(F):v(G)[F]};b.removeState=function(F){var G={};if(F!==i){G=u();$.each($.isArray(F)?F:arguments,function(I,H){delete G[H]})}q(G,2)};e[d]=$.extend(e[d],{add:function(F){var H;function G(J){var I=J[D]=c();J.getState=function(K,L){return K===i||typeof K==="boolean"?l(I,K):l(I,L)[K]};H.apply(this,arguments)}if($.isFunction(F)){H=F;return G}else{H=F.handler;F.handler=G}}})})(jQuery,this);
  28. /*
  29. * jQuery hashchange event - v1.2 - 2/11/2010
  30. * http://benalman.com/projects/jquery-hashchange-plugin/
  31. *
  32. * Copyright (c) 2010 "Cowboy" Ben Alman
  33. * Dual licensed under the MIT and GPL licenses.
  34. * http://benalman.com/about/license/
  35. */
  36. (function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);
  37. ;
  38. /**
  39. * @file
  40. * Attaches the behaviors for the Overlay parent pages.
  41. */
  42. (function ($) {
  43. /**
  44. * Open the overlay, or load content into it, when an admin link is clicked.
  45. */
  46. Drupal.behaviors.overlayParent = {
  47. attach: function (context, settings) {
  48. if (Drupal.overlay.isOpen) {
  49. Drupal.overlay.makeDocumentUntabbable(context);
  50. }
  51. if (this.processed) {
  52. return;
  53. }
  54. this.processed = true;
  55. $(window)
  56. // When the hash (URL fragment) changes, open the overlay if needed.
  57. .bind('hashchange.drupal-overlay', $.proxy(Drupal.overlay, 'eventhandlerOperateByURLFragment'))
  58. // Trigger the hashchange handler once, after the page is loaded, so that
  59. // permalinks open the overlay.
  60. .triggerHandler('hashchange.drupal-overlay');
  61. $(document)
  62. // Instead of binding a click event handler to every link we bind one to
  63. // the document and only handle events that bubble up. This allows other
  64. // scripts to bind their own handlers to links and also to prevent
  65. // overlay's handling.
  66. .bind('click.drupal-overlay mouseup.drupal-overlay', $.proxy(Drupal.overlay, 'eventhandlerOverrideLink'));
  67. }
  68. };
  69. /**
  70. * Overlay object for parent windows.
  71. *
  72. * Events
  73. * Overlay triggers a number of events that can be used by other scripts.
  74. * - drupalOverlayOpen: This event is triggered when the overlay is opened.
  75. * - drupalOverlayBeforeClose: This event is triggered when the overlay attempts
  76. * to close. If an event handler returns false, the close will be prevented.
  77. * - drupalOverlayClose: This event is triggered when the overlay is closed.
  78. * - drupalOverlayBeforeLoad: This event is triggered right before a new URL
  79. * is loaded into the overlay.
  80. * - drupalOverlayReady: This event is triggered when the DOM of the overlay
  81. * child document is fully loaded.
  82. * - drupalOverlayLoad: This event is triggered when the overlay is finished
  83. * loading.
  84. * - drupalOverlayResize: This event is triggered when the overlay is being
  85. * resized to match the parent window.
  86. */
  87. Drupal.overlay = Drupal.overlay || {
  88. isOpen: false,
  89. isOpening: false,
  90. isClosing: false,
  91. isLoading: false
  92. };
  93. Drupal.overlay.prototype = {};
  94. /**
  95. * Open the overlay.
  96. *
  97. * @param url
  98. * The URL of the page to open in the overlay.
  99. *
  100. * @return
  101. * TRUE if the overlay was opened, FALSE otherwise.
  102. */
  103. Drupal.overlay.open = function (url) {
  104. // Just one overlay is allowed.
  105. if (this.isOpen || this.isOpening) {
  106. return this.load(url);
  107. }
  108. this.isOpening = true;
  109. // Store the original document title.
  110. this.originalTitle = document.title;
  111. // Create the dialog and related DOM elements.
  112. this.create();
  113. this.isOpening = false;
  114. this.isOpen = true;
  115. $(document.documentElement).addClass('overlay-open');
  116. this.makeDocumentUntabbable();
  117. // Allow other scripts to respond to this event.
  118. $(document).trigger('drupalOverlayOpen');
  119. return this.load(url);
  120. };
  121. /**
  122. * Create the underlying markup and behaviors for the overlay.
  123. */
  124. Drupal.overlay.create = function () {
  125. this.$container = $(Drupal.theme('overlayContainer'))
  126. .appendTo(document.body);
  127. // Overlay uses transparent iframes that cover the full parent window.
  128. // When the overlay is open the scrollbar of the parent window is hidden.
  129. // Because some browsers show a white iframe background for a short moment
  130. // while loading a page into an iframe, overlay uses two iframes. By loading
  131. // the page in a hidden (inactive) iframe the user doesn't see the white
  132. // background. When the page is loaded the active and inactive iframes
  133. // are switched.
  134. this.activeFrame = this.$iframeA = $(Drupal.theme('overlayElement'))
  135. .appendTo(this.$container);
  136. this.inactiveFrame = this.$iframeB = $(Drupal.theme('overlayElement'))
  137. .appendTo(this.$container);
  138. this.$iframeA.bind('load.drupal-overlay', { self: this.$iframeA[0], sibling: this.$iframeB }, $.proxy(this, 'loadChild'));
  139. this.$iframeB.bind('load.drupal-overlay', { self: this.$iframeB[0], sibling: this.$iframeA }, $.proxy(this, 'loadChild'));
  140. // Add a second class "drupal-overlay-open" to indicate these event handlers
  141. // should only be bound when the overlay is open.
  142. var eventClass = '.drupal-overlay.drupal-overlay-open';
  143. $(window)
  144. .bind('resize' + eventClass, $.proxy(this, 'eventhandlerOuterResize'));
  145. $(document)
  146. .bind('drupalOverlayLoad' + eventClass, $.proxy(this, 'eventhandlerOuterResize'))
  147. .bind('drupalOverlayReady' + eventClass +
  148. ' drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerSyncURLFragment'))
  149. .bind('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRefreshPage'))
  150. .bind('drupalOverlayBeforeClose' + eventClass +
  151. ' drupalOverlayBeforeLoad' + eventClass +
  152. ' drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerDispatchEvent'));
  153. if ($('.overlay-displace-top, .overlay-displace-bottom').length) {
  154. $(document)
  155. .bind('drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerAlterDisplacedElements'))
  156. .bind('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRestoreDisplacedElements'));
  157. }
  158. };
  159. /**
  160. * Load the given URL into the overlay iframe.
  161. *
  162. * Use this method to change the URL being loaded in the overlay if it is
  163. * already open.
  164. *
  165. * @return
  166. * TRUE if URL is loaded into the overlay, FALSE otherwise.
  167. */
  168. Drupal.overlay.load = function (url) {
  169. if (!this.isOpen) {
  170. return false;
  171. }
  172. // Allow other scripts to respond to this event.
  173. $(document).trigger('drupalOverlayBeforeLoad');
  174. $(document.documentElement).addClass('overlay-loading');
  175. // The contentDocument property is not supported in IE until IE8.
  176. var iframeDocument = this.inactiveFrame[0].contentDocument || this.inactiveFrame[0].contentWindow.document;
  177. // location.replace doesn't create a history entry. location.href does.
  178. // In this case, we want location.replace, as we're creating the history
  179. // entry using URL fragments.
  180. iframeDocument.location.replace(url);
  181. return true;
  182. };
  183. /**
  184. * Close the overlay and remove markup related to it from the document.
  185. *
  186. * @return
  187. * TRUE if the overlay was closed, FALSE otherwise.
  188. */
  189. Drupal.overlay.close = function () {
  190. // Prevent double execution when close is requested more than once.
  191. if (!this.isOpen || this.isClosing) {
  192. return false;
  193. }
  194. // Allow other scripts to respond to this event.
  195. var event = $.Event('drupalOverlayBeforeClose');
  196. $(document).trigger(event);
  197. // If a handler returned false, the close will be prevented.
  198. if (event.isDefaultPrevented()) {
  199. return false;
  200. }
  201. this.isClosing = true;
  202. this.isOpen = false;
  203. $(document.documentElement).removeClass('overlay-open');
  204. // Restore the original document title.
  205. document.title = this.originalTitle;
  206. this.makeDocumentTabbable();
  207. // Allow other scripts to respond to this event.
  208. $(document).trigger('drupalOverlayClose');
  209. // When the iframe is still loading don't destroy it immediately but after
  210. // the content is loaded (see Drupal.overlay.loadChild).
  211. if (!this.isLoading) {
  212. this.destroy();
  213. this.isClosing = false;
  214. }
  215. return true;
  216. };
  217. /**
  218. * Destroy the overlay.
  219. */
  220. Drupal.overlay.destroy = function () {
  221. $([document, window]).unbind('.drupal-overlay-open');
  222. this.$container.remove();
  223. this.$container = null;
  224. this.$iframeA = null;
  225. this.$iframeB = null;
  226. this.iframeWindow = null;
  227. };
  228. /**
  229. * Redirect the overlay parent window to the given URL.
  230. *
  231. * @param url
  232. * Can be an absolute URL or a relative link to the domain root.
  233. */
  234. Drupal.overlay.redirect = function (url) {
  235. // Create a native Link object, so we can use its object methods.
  236. var link = $(url.link(url)).get(0);
  237. // If the link is already open, force the hashchange event to simulate reload.
  238. if (window.location.href == link.href) {
  239. $(window).triggerHandler('hashchange.drupal-overlay');
  240. }
  241. window.location.href = link.href;
  242. return true;
  243. };
  244. /**
  245. * Bind the child window.
  246. *
  247. * Note that this function is fired earlier than Drupal.overlay.loadChild.
  248. */
  249. Drupal.overlay.bindChild = function (iframeWindow, isClosing) {
  250. this.iframeWindow = iframeWindow;
  251. // We are done if the child window is closing.
  252. if (isClosing || this.isClosing || !this.isOpen) {
  253. return;
  254. }
  255. // Allow other scripts to respond to this event.
  256. $(document).trigger('drupalOverlayReady');
  257. };
  258. /**
  259. * Event handler: load event handler for the overlay iframe.
  260. *
  261. * @param event
  262. * Event being triggered, with the following restrictions:
  263. * - event.type: load
  264. * - event.currentTarget: iframe
  265. */
  266. Drupal.overlay.loadChild = function (event) {
  267. var iframe = event.data.self;
  268. var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
  269. var iframeWindow = iframeDocument.defaultView || iframeDocument.parentWindow;
  270. if (iframeWindow.location == 'about:blank') {
  271. return;
  272. }
  273. this.isLoading = false;
  274. $(document.documentElement).removeClass('overlay-loading');
  275. event.data.sibling.removeClass('overlay-active').attr({ 'tabindex': -1 });
  276. // Only continue when overlay is still open and not closing.
  277. if (this.isOpen && !this.isClosing) {
  278. // And child document is an actual overlayChild.
  279. if (iframeWindow.Drupal && iframeWindow.Drupal.overlayChild) {
  280. // Replace the document title with title of iframe.
  281. document.title = iframeWindow.document.title;
  282. this.activeFrame = $(iframe)
  283. .addClass('overlay-active')
  284. // Add a title attribute to the iframe for accessibility.
  285. .attr('title', Drupal.t('@title dialog', { '@title': iframeWindow.jQuery('#overlay-title').text() })).removeAttr('tabindex');
  286. this.inactiveFrame = event.data.sibling;
  287. // Load an empty document into the inactive iframe.
  288. (this.inactiveFrame[0].contentDocument || this.inactiveFrame[0].contentWindow.document).location.replace('about:blank');
  289. // Move the focus to just before the "skip to main content" link inside
  290. // the overlay.
  291. this.activeFrame.focus();
  292. var skipLink = iframeWindow.jQuery('a:first');
  293. Drupal.overlay.setFocusBefore(skipLink, iframeWindow.document);
  294. // Allow other scripts to respond to this event.
  295. $(document).trigger('drupalOverlayLoad');
  296. }
  297. else {
  298. window.location = iframeWindow.location.href.replace(/([?&]?)render=overlay&?/g, '$1').replace(/\?$/, '');
  299. }
  300. }
  301. else {
  302. this.destroy();
  303. }
  304. };
  305. /**
  306. * Creates a placeholder element to receive document focus.
  307. *
  308. * Setting the document focus to a link will make it visible, even if it's a
  309. * "skip to main content" link that should normally be visible only when the
  310. * user tabs to it. This function can be used to set the document focus to
  311. * just before such an invisible link.
  312. *
  313. * @param $element
  314. * The jQuery element that should receive focus on the next tab press.
  315. * @param document
  316. * The iframe window element to which the placeholder should be added. The
  317. * placeholder element has to be created inside the same iframe as the element
  318. * it precedes, to keep IE happy. (http://bugs.jquery.com/ticket/4059)
  319. */
  320. Drupal.overlay.setFocusBefore = function ($element, document) {
  321. // Create an anchor inside the placeholder document.
  322. var placeholder = document.createElement('a');
  323. var $placeholder = $(placeholder).addClass('element-invisible').attr('href', '#');
  324. // Put the placeholder where it belongs, and set the document focus to it.
  325. $placeholder.insertBefore($element);
  326. $placeholder.focus();
  327. // Make the placeholder disappear as soon as it loses focus, so that it
  328. // doesn't appear in the tab order again.
  329. $placeholder.one('blur', function () {
  330. $(this).remove();
  331. });
  332. };
  333. /**
  334. * Check if the given link is in the administrative section of the site.
  335. *
  336. * @param url
  337. * The URL to be tested.
  338. *
  339. * @return boolean
  340. * TRUE if the URL represents an administrative link, FALSE otherwise.
  341. */
  342. Drupal.overlay.isAdminLink = function (url) {
  343. if (Drupal.overlay.isExternalLink(url)) {
  344. return false;
  345. }
  346. var path = this.getPath(url);
  347. // Turn the list of administrative paths into a regular expression.
  348. if (!this.adminPathRegExp) {
  349. var prefix = '';
  350. if (Drupal.settings.overlay.pathPrefixes.length) {
  351. // Allow path prefixes used for language negatiation followed by slash,
  352. // and the empty string.
  353. prefix = '(' + Drupal.settings.overlay.pathPrefixes.join('/|') + '/|)';
  354. }
  355. var adminPaths = '^' + prefix + '(' + Drupal.settings.overlay.paths.admin.replace(/\s+/g, '|') + ')$';
  356. var nonAdminPaths = '^' + prefix + '(' + Drupal.settings.overlay.paths.non_admin.replace(/\s+/g, '|') + ')$';
  357. adminPaths = adminPaths.replace(/\*/g, '.*');
  358. nonAdminPaths = nonAdminPaths.replace(/\*/g, '.*');
  359. this.adminPathRegExp = new RegExp(adminPaths);
  360. this.nonAdminPathRegExp = new RegExp(nonAdminPaths);
  361. }
  362. return this.adminPathRegExp.exec(path) && !this.nonAdminPathRegExp.exec(path);
  363. };
  364. /**
  365. * Determine whether a link is external to the site.
  366. *
  367. * @param url
  368. * The URL to be tested.
  369. *
  370. * @return boolean
  371. * TRUE if the URL is external to the site, FALSE otherwise.
  372. */
  373. Drupal.overlay.isExternalLink = function (url) {
  374. var re = RegExp('^((f|ht)tps?:)?//(?!' + window.location.host + ')');
  375. return re.test(url);
  376. };
  377. /**
  378. * Event handler: resizes overlay according to the size of the parent window.
  379. *
  380. * @param event
  381. * Event being triggered, with the following restrictions:
  382. * - event.type: any
  383. * - event.currentTarget: any
  384. */
  385. Drupal.overlay.eventhandlerOuterResize = function (event) {
  386. // Proceed only if the overlay still exists.
  387. if (!(this.isOpen || this.isOpening) || this.isClosing || !this.iframeWindow) {
  388. return;
  389. }
  390. // IE6 uses position:absolute instead of position:fixed.
  391. if (typeof document.body.style.maxHeight != 'string') {
  392. this.activeFrame.height($(window).height());
  393. }
  394. // Allow other scripts to respond to this event.
  395. $(document).trigger('drupalOverlayResize');
  396. };
  397. /**
  398. * Event handler: resizes displaced elements so they won't overlap the scrollbar
  399. * of overlay's iframe.
  400. *
  401. * @param event
  402. * Event being triggered, with the following restrictions:
  403. * - event.type: any
  404. * - event.currentTarget: any
  405. */
  406. Drupal.overlay.eventhandlerAlterDisplacedElements = function (event) {
  407. // Proceed only if the overlay still exists.
  408. if (!(this.isOpen || this.isOpening) || this.isClosing || !this.iframeWindow) {
  409. return;
  410. }
  411. $(this.iframeWindow.document.body).css({
  412. marginTop: Drupal.overlay.getDisplacement('top'),
  413. marginBottom: Drupal.overlay.getDisplacement('bottom')
  414. })
  415. // IE7 isn't reflowing the document immediately.
  416. // @todo This might be fixed in a cleaner way.
  417. .addClass('overlay-trigger-reflow').removeClass('overlay-trigger-reflow');
  418. var documentHeight = this.iframeWindow.document.body.clientHeight;
  419. var documentWidth = this.iframeWindow.document.body.clientWidth;
  420. // IE6 doesn't support maxWidth, use width instead.
  421. var maxWidthName = (typeof document.body.style.maxWidth == 'string') ? 'maxWidth' : 'width';
  422. if (Drupal.overlay.leftSidedScrollbarOffset === undefined && $(document.documentElement).attr('dir') === 'rtl') {
  423. // We can't use element.clientLeft to detect whether scrollbars are placed
  424. // on the left side of the element when direction is set to "rtl" as most
  425. // browsers dont't support it correctly.
  426. // http://www.gtalbot.org/BugzillaSection/DocumentAllDHTMLproperties.html
  427. // There seems to be absolutely no way to detect whether the scrollbar
  428. // is on the left side in Opera; always expect scrollbar to be on the left.
  429. if ($.browser.opera) {
  430. Drupal.overlay.leftSidedScrollbarOffset = document.documentElement.clientWidth - this.iframeWindow.document.documentElement.clientWidth + this.iframeWindow.document.documentElement.clientLeft;
  431. }
  432. else if (this.iframeWindow.document.documentElement.clientLeft) {
  433. Drupal.overlay.leftSidedScrollbarOffset = this.iframeWindow.document.documentElement.clientLeft;
  434. }
  435. else {
  436. var el1 = $('<div style="direction: rtl; overflow: scroll;"></div>').appendTo(document.body);
  437. var el2 = $('<div></div>').appendTo(el1);
  438. Drupal.overlay.leftSidedScrollbarOffset = parseInt(el2[0].offsetLeft - el1[0].offsetLeft);
  439. el1.remove();
  440. }
  441. }
  442. // Consider any element that should be visible above the overlay (such as
  443. // a toolbar).
  444. $('.overlay-displace-top, .overlay-displace-bottom').each(function () {
  445. var data = $(this).data();
  446. var maxWidth = documentWidth;
  447. // In IE, Shadow filter makes element to overlap the scrollbar with 1px.
  448. if (this.filters && this.filters.length && this.filters.item('DXImageTransform.Microsoft.Shadow')) {
  449. maxWidth -= 1;
  450. }
  451. if (Drupal.overlay.leftSidedScrollbarOffset) {
  452. $(this).css('left', Drupal.overlay.leftSidedScrollbarOffset);
  453. }
  454. // Prevent displaced elements overlapping window's scrollbar.
  455. var currentMaxWidth = parseInt($(this).css(maxWidthName));
  456. if ((data.drupalOverlay && data.drupalOverlay.maxWidth) || isNaN(currentMaxWidth) || currentMaxWidth > maxWidth || currentMaxWidth <= 0) {
  457. $(this).css(maxWidthName, maxWidth);
  458. (data.drupalOverlay = data.drupalOverlay || {}).maxWidth = true;
  459. }
  460. // Use a more rigorous approach if the displaced element still overlaps
  461. // window's scrollbar; clip the element on the right.
  462. var offset = $(this).offset();
  463. var offsetRight = offset.left + $(this).outerWidth();
  464. if ((data.drupalOverlay && data.drupalOverlay.clip) || offsetRight > maxWidth) {
  465. if (Drupal.overlay.leftSidedScrollbarOffset) {
  466. $(this).css('clip', 'rect(auto, auto, ' + (documentHeight - offset.top) + 'px, ' + (Drupal.overlay.leftSidedScrollbarOffset + 2) + 'px)');
  467. }
  468. else {
  469. $(this).css('clip', 'rect(auto, ' + (maxWidth - offset.left) + 'px, ' + (documentHeight - offset.top) + 'px, auto)');
  470. }
  471. (data.drupalOverlay = data.drupalOverlay || {}).clip = true;
  472. }
  473. });
  474. };
  475. /**
  476. * Event handler: restores size of displaced elements as they were before
  477. * overlay was opened.
  478. *
  479. * @param event
  480. * Event being triggered, with the following restrictions:
  481. * - event.type: any
  482. * - event.currentTarget: any
  483. */
  484. Drupal.overlay.eventhandlerRestoreDisplacedElements = function (event) {
  485. var $displacedElements = $('.overlay-displace-top, .overlay-displace-bottom');
  486. try {
  487. $displacedElements.css({ maxWidth: '', clip: '' });
  488. }
  489. // IE bug that doesn't allow unsetting style.clip (http://dev.jquery.com/ticket/6512).
  490. catch (err) {
  491. $displacedElements.attr('style', function (index, attr) {
  492. return attr.replace(/clip\s*:\s*rect\([^)]+\);?/i, '');
  493. });
  494. }
  495. };
  496. /**
  497. * Event handler: overrides href of administrative links to be opened in
  498. * the overlay.
  499. *
  500. * This click event handler should be bound to any document (for example the
  501. * overlay iframe) of which you want links to open in the overlay.
  502. *
  503. * @param event
  504. * Event being triggered, with the following restrictions:
  505. * - event.type: click, mouseup
  506. * - event.currentTarget: document
  507. *
  508. * @see Drupal.overlayChild.behaviors.addClickHandler
  509. */
  510. Drupal.overlay.eventhandlerOverrideLink = function (event) {
  511. // In some browsers the click event isn't fired for right-clicks. Use the
  512. // mouseup event for right-clicks and the click event for everything else.
  513. if ((event.type == 'click' && event.button == 2) || (event.type == 'mouseup' && event.button != 2)) {
  514. return;
  515. }
  516. var $target = $(event.target);
  517. // Only continue if clicked target (or one of its parents) is a link.
  518. if (!$target.is('a')) {
  519. $target = $target.closest('a');
  520. if (!$target.length) {
  521. return;
  522. }
  523. }
  524. // Never open links in the overlay that contain the overlay-exclude class.
  525. if ($target.hasClass('overlay-exclude')) {
  526. return;
  527. }
  528. // Close the overlay when the link contains the overlay-close class.
  529. if ($target.hasClass('overlay-close')) {
  530. // Clearing the overlay URL fragment will close the overlay.
  531. $.bbq.removeState('overlay');
  532. return;
  533. }
  534. var target = $target[0];
  535. var href = target.href;
  536. // Only handle links that have an href attribute and use the HTTP(S) protocol.
  537. if (href != undefined && href != '' && target.protocol.match(/^https?\:/)) {
  538. var anchor = href.replace(target.ownerDocument.location.href, '');
  539. // Skip anchor links.
  540. if (anchor.length == 0 || anchor.charAt(0) == '#') {
  541. return;
  542. }
  543. // Open admin links in the overlay.
  544. else if (this.isAdminLink(href)) {
  545. // If the link contains the overlay-restore class and the overlay-context
  546. // state is set, also update the parent window's location.
  547. var parentLocation = ($target.hasClass('overlay-restore') && typeof $.bbq.getState('overlay-context') == 'string')
  548. ? Drupal.settings.basePath + $.bbq.getState('overlay-context')
  549. : null;
  550. href = this.fragmentizeLink($target.get(0), parentLocation);
  551. // Only override default behavior when left-clicking and user is not
  552. // pressing the ALT, CTRL, META (Command key on the Macintosh keyboard)
  553. // or SHIFT key.
  554. if (event.button == 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
  555. // Redirect to a fragmentized href. This will trigger a hashchange event.
  556. this.redirect(href);
  557. // Prevent default action and further propagation of the event.
  558. return false;
  559. }
  560. // Otherwise alter clicked link's href. This is being picked up by
  561. // the default action handler.
  562. else {
  563. $target
  564. // Restore link's href attribute on blur or next click.
  565. .one('blur mousedown', { target: target, href: target.href }, function (event) { $(event.data.target).attr('href', event.data.href); })
  566. .attr('href', href);
  567. }
  568. }
  569. // Non-admin links should close the overlay and open in the main window,
  570. // which is the default action for a link. We only need to handle them
  571. // if the overlay is open and the clicked link is inside the overlay iframe.
  572. else if (this.isOpen && target.ownerDocument === this.iframeWindow.document) {
  573. // Open external links in the immediate parent of the frame, unless the
  574. // link already has a different target.
  575. if (target.hostname != window.location.hostname) {
  576. if (!$target.attr('target')) {
  577. $target.attr('target', '_parent');
  578. }
  579. }
  580. else {
  581. // Add the overlay-context state to the link, so "overlay-restore" links
  582. // can restore the context.
  583. if ($target[0].hash) {
  584. // Leave links with an existing fragment alone. Adding an extra
  585. // parameter to a link like "node/1#section-1" breaks the link.
  586. }
  587. else {
  588. // For links with no existing fragment, add the overlay context.
  589. $target.attr('href', $.param.fragment(href, { 'overlay-context': this.getPath(window.location) + window.location.search }));
  590. }
  591. // When the link has a destination query parameter and that destination
  592. // is an admin link we need to fragmentize it. This will make it reopen
  593. // in the overlay.
  594. var params = $.deparam.querystring(href);
  595. if (params.destination && this.isAdminLink(params.destination)) {
  596. var fragmentizedDestination = $.param.fragment(this.getPath(window.location), { overlay: params.destination });
  597. $target.attr('href', $.param.querystring(href, { destination: fragmentizedDestination }));
  598. }
  599. // Make the link open in the immediate parent of the frame, unless the
  600. // link already has a different target.
  601. if (!$target.attr('target')) {
  602. $target.attr('target', '_parent');
  603. }
  604. }
  605. }
  606. }
  607. };
  608. /**
  609. * Event handler: opens or closes the overlay based on the current URL fragment.
  610. *
  611. * @param event
  612. * Event being triggered, with the following restrictions:
  613. * - event.type: hashchange
  614. * - event.currentTarget: document
  615. */
  616. Drupal.overlay.eventhandlerOperateByURLFragment = function (event) {
  617. // If we changed the hash to reflect an internal redirect in the overlay,
  618. // its location has already been changed, so don't do anything.
  619. if ($.data(window.location, window.location.href) === 'redirect') {
  620. $.data(window.location, window.location.href, null);
  621. return;
  622. }
  623. // Get the overlay URL from the current URL fragment.
  624. var state = $.bbq.getState('overlay');
  625. if (state) {
  626. // Append render variable, so the server side can choose the right
  627. // rendering and add child frame code to the page if needed.
  628. var url = $.param.querystring(Drupal.settings.basePath + state, { render: 'overlay' });
  629. this.open(url);
  630. this.resetActiveClass(this.getPath(Drupal.settings.basePath + state));
  631. }
  632. // If there is no overlay URL in the fragment and the overlay is (still)
  633. // open, close the overlay.
  634. else if (this.isOpen && !this.isClosing) {
  635. this.close();
  636. this.resetActiveClass(this.getPath(window.location));
  637. }
  638. };
  639. /**
  640. * Event handler: makes sure the internal overlay URL is reflected in the parent
  641. * URL fragment.
  642. *
  643. * Normally the parent URL fragment determines the overlay location. However, if
  644. * the overlay redirects internally, the parent doesn't get informed, and the
  645. * parent URL fragment will be out of date. This is a sanity check to make
  646. * sure we're in the right place.
  647. *
  648. * The parent URL fragment is also not updated automatically when overlay's
  649. * open, close or load functions are used directly (instead of through
  650. * eventhandlerOperateByURLFragment).
  651. *
  652. * @param event
  653. * Event being triggered, with the following restrictions:
  654. * - event.type: drupalOverlayReady, drupalOverlayClose
  655. * - event.currentTarget: document
  656. */
  657. Drupal.overlay.eventhandlerSyncURLFragment = function (event) {
  658. if (this.isOpen) {
  659. var expected = $.bbq.getState('overlay');
  660. // This is just a sanity check, so we're comparing paths, not query strings.
  661. if (this.getPath(Drupal.settings.basePath + expected) != this.getPath(this.iframeWindow.document.location)) {
  662. // There may have been a redirect inside the child overlay window that the
  663. // parent wasn't aware of. Update the parent URL fragment appropriately.
  664. var newLocation = Drupal.overlay.fragmentizeLink(this.iframeWindow.document.location);
  665. // Set a 'redirect' flag on the new location so the hashchange event handler
  666. // knows not to change the overlay's content.
  667. $.data(window.location, newLocation, 'redirect');
  668. // Use location.replace() so we don't create an extra history entry.
  669. window.location.replace(newLocation);
  670. }
  671. }
  672. else {
  673. $.bbq.removeState('overlay');
  674. }
  675. };
  676. /**
  677. * Event handler: if the child window suggested that the parent refresh on
  678. * close, force a page refresh.
  679. *
  680. * @param event
  681. * Event being triggered, with the following restrictions:
  682. * - event.type: drupalOverlayClose
  683. * - event.currentTarget: document
  684. */
  685. Drupal.overlay.eventhandlerRefreshPage = function (event) {
  686. if (Drupal.overlay.refreshPage) {
  687. window.location.reload(true);
  688. }
  689. };
  690. /**
  691. * Event handler: dispatches events to the overlay document.
  692. *
  693. * @param event
  694. * Event being triggered, with the following restrictions:
  695. * - event.type: any
  696. * - event.currentTarget: any
  697. */
  698. Drupal.overlay.eventhandlerDispatchEvent = function (event) {
  699. if (this.iframeWindow && this.iframeWindow.document) {
  700. this.iframeWindow.jQuery(this.iframeWindow.document).trigger(event);
  701. }
  702. };
  703. /**
  704. * Make a regular admin link into a URL that will trigger the overlay to open.
  705. *
  706. * @param link
  707. * A JavaScript Link object (i.e. an <a> element).
  708. * @param parentLocation
  709. * (optional) URL to override the parent window's location with.
  710. *
  711. * @return
  712. * A URL that will trigger the overlay (in the form
  713. * /node/1#overlay=admin/config).
  714. */
  715. Drupal.overlay.fragmentizeLink = function (link, parentLocation) {
  716. // Don't operate on links that are already overlay-ready.
  717. var params = $.deparam.fragment(link.href);
  718. if (params.overlay) {
  719. return link.href;
  720. }
  721. // Determine the link's original destination. Set ignorePathFromQueryString to
  722. // true to prevent transforming this link into a clean URL while clean URLs
  723. // may be disabled.
  724. var path = this.getPath(link, true);
  725. // Preserve existing query and fragment parameters in the URL, except for
  726. // "render=overlay" which is re-added in Drupal.overlay.eventhandlerOperateByURLFragment.
  727. var destination = path + link.search.replace(/&?render=overlay/, '').replace(/\?$/, '') + link.hash;
  728. // Assemble and return the overlay-ready link.
  729. return $.param.fragment(parentLocation || window.location.href, { overlay: destination });
  730. };
  731. /**
  732. * Refresh any regions of the page that are displayed outside the overlay.
  733. *
  734. * @param data
  735. * An array of objects with information on the page regions to be refreshed.
  736. * For each object, the key is a CSS class identifying the region to be
  737. * refreshed, and the value represents the section of the Drupal $page array
  738. * corresponding to this region.
  739. */
  740. Drupal.overlay.refreshRegions = function (data) {
  741. $.each(data, function () {
  742. var region_info = this;
  743. $.each(region_info, function (regionClass) {
  744. var regionName = region_info[regionClass];
  745. var regionSelector = '.' + regionClass;
  746. // Allow special behaviors to detach.
  747. Drupal.detachBehaviors($(regionSelector));
  748. $.get(Drupal.settings.basePath + Drupal.settings.overlay.ajaxCallback + '/' + regionName, function (newElement) {
  749. $(regionSelector).replaceWith($(newElement));
  750. Drupal.attachBehaviors($(regionSelector), Drupal.settings);
  751. });
  752. });
  753. });
  754. };
  755. /**
  756. * Reset the active class on links in displaced elements according to
  757. * given path.
  758. *
  759. * @param activePath
  760. * Path to match links against.
  761. */
  762. Drupal.overlay.resetActiveClass = function(activePath) {
  763. var self = this;
  764. var windowDomain = window.location.protocol + window.location.hostname;
  765. $('.overlay-displace-top, .overlay-displace-bottom')
  766. .find('a[href]')
  767. // Remove active class from all links in displaced elements.
  768. .removeClass('active')
  769. // Add active class to links that match activePath.
  770. .each(function () {
  771. var linkDomain = this.protocol + this.hostname;
  772. var linkPath = self.getPath(this);
  773. // A link matches if it is part of the active trail of activePath, except
  774. // for frontpage links.
  775. if (linkDomain == windowDomain && (activePath + '/').indexOf(linkPath + '/') === 0 && (linkPath !== '' || activePath === '')) {
  776. $(this).addClass('active');
  777. }
  778. });
  779. };
  780. /**
  781. * Helper function to get the (corrected) Drupal path of a link.
  782. *
  783. * @param link
  784. * Link object or string to get the Drupal path from.
  785. * @param ignorePathFromQueryString
  786. * Boolean whether to ignore path from query string if path appears empty.
  787. *
  788. * @return
  789. * The Drupal path.
  790. */
  791. Drupal.overlay.getPath = function (link, ignorePathFromQueryString) {
  792. if (typeof link == 'string') {
  793. // Create a native Link object, so we can use its object methods.
  794. link = $(link.link(link)).get(0);
  795. }
  796. var path = link.pathname;
  797. // Ensure a leading slash on the path, omitted in some browsers.
  798. if (path.charAt(0) != '/') {
  799. path = '/' + path;
  800. }
  801. path = path.replace(new RegExp(Drupal.settings.basePath + '(?:index.php)?'), '');
  802. if (path == '' && !ignorePathFromQueryString) {
  803. // If the path appears empty, it might mean the path is represented in the
  804. // query string (clean URLs are not used).
  805. var match = new RegExp('([?&])q=(.+)([&#]|$)').exec(link.search);
  806. if (match && match.length == 4) {
  807. path = match[2];
  808. }
  809. }
  810. return path;
  811. };
  812. /**
  813. * Get the total displacement of given region.
  814. *
  815. * @param region
  816. * Region name. Either "top" or "bottom".
  817. *
  818. * @return
  819. * The total displacement of given region in pixels.
  820. */
  821. Drupal.overlay.getDisplacement = function (region) {
  822. var displacement = 0;
  823. var lastDisplaced = $('.overlay-displace-' + region + ':last');
  824. if (lastDisplaced.length) {
  825. displacement = lastDisplaced.offset().top + lastDisplaced.outerHeight();
  826. // In modern browsers (including IE9), when box-shadow is defined, use the
  827. // normal height.
  828. var cssBoxShadowValue = lastDisplaced.css('box-shadow');
  829. var boxShadow = (typeof cssBoxShadowValue !== 'undefined' && cssBoxShadowValue !== 'none');
  830. // In IE8 and below, we use the shadow filter to apply box-shadow styles to
  831. // the toolbar. It adds some extra height that we need to remove.
  832. if (!boxShadow && /DXImageTransform\.Microsoft\.Shadow/.test(lastDisplaced.css('filter'))) {
  833. displacement -= lastDisplaced[0].filters.item('DXImageTransform.Microsoft.Shadow').strength;
  834. displacement = Math.max(0, displacement);
  835. }
  836. }
  837. return displacement;
  838. };
  839. /**
  840. * Makes elements outside the overlay unreachable via the tab key.
  841. *
  842. * @param context
  843. * The part of the DOM that should have its tabindexes changed. Defaults to
  844. * the entire page.
  845. */
  846. Drupal.overlay.makeDocumentUntabbable = function (context) {
  847. // Manipulating tabindexes for the entire document is unacceptably slow in IE6
  848. // and IE7, so in those browsers, the underlying page will still be reachable
  849. // via the tab key. However, we still make the links within the Disable
  850. // message unreachable, because the same message also exists within the
  851. // child document. The duplicate copy in the underlying document is only for
  852. // assisting screen-reader users navigating the document with reading commands
  853. // that follow markup order rather than tab order.
  854. if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 8) {
  855. $('#overlay-disable-message a', context).attr('tabindex', -1);
  856. return;
  857. }
  858. context = context || document.body;
  859. var $overlay, $tabbable, $hasTabindex;
  860. // Determine which elements on the page already have a tabindex.
  861. $hasTabindex = $('[tabindex] :not(.overlay-element)', context);
  862. // Record the tabindex for each element, so we can restore it later.
  863. $hasTabindex.each(Drupal.overlay._recordTabindex);
  864. // Add the tabbable elements from the current context to any that we might
  865. // have previously recorded.
  866. Drupal.overlay._hasTabindex = $hasTabindex.add(Drupal.overlay._hasTabindex);
  867. // Set tabindex to -1 on everything outside the overlay and toolbars, so that
  868. // the underlying page is unreachable.
  869. // By default, browsers make a, area, button, input, object, select, textarea,
  870. // and iframe elements reachable via the tab key.
  871. $tabbable = $('a, area, button, input, object, select, textarea, iframe');
  872. // If another element (like a div) has a tabindex, it's also tabbable.
  873. $tabbable = $tabbable.add($hasTabindex);
  874. // Leave links inside the overlay and toolbars alone.
  875. $overlay = $('.overlay-element, #overlay-container, .overlay-displace-top, .overlay-displace-bottom').find('*');
  876. $tabbable = $tabbable.not($overlay);
  877. // We now have a list of everything in the underlying document that could
  878. // possibly be reachable via the tab key. Make it all unreachable.
  879. $tabbable.attr('tabindex', -1);
  880. };
  881. /**
  882. * Restores the original tabindex value of a group of elements.
  883. *
  884. * @param context
  885. * The part of the DOM that should have its tabindexes restored. Defaults to
  886. * the entire page.
  887. */
  888. Drupal.overlay.makeDocumentTabbable = function (context) {
  889. // Manipulating tabindexes is unacceptably slow in IE6 and IE7. In those
  890. // browsers, the underlying page was never made unreachable via tab, so
  891. // there is no work to be done here.
  892. if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 8) {
  893. return;
  894. }
  895. var $needsTabindex;
  896. context = context || document.body;
  897. // Make the underlying document tabbable again by removing all existing
  898. // tabindex attributes.
  899. var $tabindex = $('[tabindex]', context);
  900. if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 8) {
  901. // removeAttr('tabindex') is broken in IE6-7, but the DOM function
  902. // removeAttribute works.
  903. var i;
  904. var length = $tabindex.length;
  905. for (i = 0; i < length; i++) {
  906. $tabindex[i].removeAttribute('tabIndex');
  907. }
  908. }
  909. else {
  910. $tabindex.removeAttr('tabindex');
  911. }
  912. // Restore the tabindex attributes that existed before the overlay was opened.
  913. $needsTabindex = $(Drupal.overlay._hasTabindex, context);
  914. $needsTabindex.each(Drupal.overlay._restoreTabindex);
  915. Drupal.overlay._hasTabindex = Drupal.overlay._hasTabindex.not($needsTabindex);
  916. };
  917. /**
  918. * Record the tabindex for an element, using $.data.
  919. *
  920. * Meant to be used as a jQuery.fn.each callback.
  921. */
  922. Drupal.overlay._recordTabindex = function () {
  923. var $element = $(this);
  924. var tabindex = $(this).attr('tabindex');
  925. $element.data('drupalOverlayOriginalTabIndex', tabindex);
  926. };
  927. /**
  928. * Restore an element's original tabindex.
  929. *
  930. * Meant to be used as a jQuery.fn.each callback.
  931. */
  932. Drupal.overlay._restoreTabindex = function () {
  933. var $element = $(this);
  934. var tabindex = $element.data('drupalOverlayOriginalTabIndex');
  935. $element.attr('tabindex', tabindex);
  936. };
  937. /**
  938. * Theme function to create the overlay iframe element.
  939. */
  940. Drupal.theme.prototype.overlayContainer = function () {
  941. return '<div id="overlay-container"><div class="overlay-modal-background"></div></div>';
  942. };
  943. /**
  944. * Theme function to create an overlay iframe element.
  945. */
  946. Drupal.theme.prototype.overlayElement = function (url) {
  947. return '<iframe class="overlay-element" frameborder="0" scrolling="auto" allowtransparency="true"></iframe>';
  948. };
  949. })(jQuery);
  950. ;
  951. /**
  952. * @file
  953. * Attaches behaviors for the Contextual module.
  954. */
  955. (function ($) {
  956. Drupal.contextualLinks = Drupal.contextualLinks || {};
  957. /**
  958. * Attaches outline behavior for regions associated with contextual links.
  959. */
  960. Drupal.behaviors.contextualLinks = {
  961. attach: function (context) {
  962. $('div.contextual-links-wrapper', context).once('contextual-links', function () {
  963. var $wrapper = $(this);
  964. var $region = $wrapper.closest('.contextual-links-region');
  965. var $links = $wrapper.find('ul.contextual-links');
  966. var $trigger = $('<a class="contextual-links-trigger" href="#" />').text(Drupal.t('Configure')).click(
  967. function () {
  968. $links.stop(true, true).slideToggle(100);
  969. $wrapper.toggleClass('contextual-links-active');
  970. return false;
  971. }
  972. );
  973. // Attach hover behavior to trigger and ul.contextual-links.
  974. $trigger.add($links).hover(
  975. function () { $region.addClass('contextual-links-region-active'); },
  976. function () { $region.removeClass('contextual-links-region-active'); }
  977. );
  978. // Hide the contextual links when user clicks a link or rolls out of the .contextual-links-region.
  979. $region.bind('mouseleave click', Drupal.contextualLinks.mouseleave);
  980. $region.hover(
  981. function() { $trigger.addClass('contextual-links-trigger-active'); },
  982. function() { $trigger.removeClass('contextual-links-trigger-active'); }
  983. );
  984. // Prepend the trigger.
  985. $wrapper.prepend($trigger);
  986. });
  987. }
  988. };
  989. /**
  990. * Disables outline for the region contextual links are associated with.
  991. */
  992. Drupal.contextualLinks.mouseleave = function () {
  993. $(this)
  994. .find('.contextual-links-active').removeClass('contextual-links-active')
  995. .find('ul.contextual-links').hide();
  996. };
  997. })(jQuery);
  998. ;
  999. /**
  1000. * Cookie plugin 1.0
  1001. *
  1002. * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
  1003. * Dual licensed under the MIT and GPL licenses:
  1004. * http://www.opensource.org/licenses/mit-license.php
  1005. * http://www.gnu.org/licenses/gpl.html
  1006. *
  1007. */
  1008. 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}};
  1009. ;