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