1 |
85ad3d82
|
Assos Assos
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
(function ($) {
|
12 |
|
|
|
13 |
|
|
Drupal.CTools = Drupal.CTools || {};
|
14 |
|
|
Drupal.CTools.Modal = Drupal.CTools.Modal || {};
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
Drupal.CTools.Modal.show = function(choice) {
|
22 |
|
|
var opts = {};
|
23 |
|
|
|
24 |
|
|
if (choice && typeof choice == 'string' && Drupal.settings[choice]) {
|
25 |
|
|
|
26 |
|
|
$.extend(true, opts, Drupal.settings[choice]);
|
27 |
|
|
}
|
28 |
|
|
else if (choice) {
|
29 |
|
|
$.extend(true, opts, choice);
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
var defaults = {
|
33 |
|
|
modalTheme: 'CToolsModalDialog',
|
34 |
|
|
throbberTheme: 'CToolsModalThrobber',
|
35 |
|
|
animation: 'show',
|
36 |
|
|
animationSpeed: 'fast',
|
37 |
|
|
modalSize: {
|
38 |
|
|
type: 'scale',
|
39 |
|
|
width: .8,
|
40 |
|
|
height: .8,
|
41 |
|
|
addWidth: 0,
|
42 |
|
|
addHeight: 0,
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
contentRight: 25,
|
46 |
|
|
contentBottom: 45
|
47 |
|
|
},
|
48 |
|
|
modalOptions: {
|
49 |
|
|
opacity: .55,
|
50 |
|
|
background: '#fff'
|
51 |
560c3060
|
Julien Enselme
|
},
|
52 |
|
|
modalClass: 'default'
|
53 |
85ad3d82
|
Assos Assos
|
};
|
54 |
|
|
|
55 |
|
|
var settings = {};
|
56 |
|
|
$.extend(true, settings, defaults, Drupal.settings.CToolsModal, opts);
|
57 |
|
|
|
58 |
|
|
if (Drupal.CTools.Modal.currentSettings && Drupal.CTools.Modal.currentSettings != settings) {
|
59 |
|
|
Drupal.CTools.Modal.modal.remove();
|
60 |
|
|
Drupal.CTools.Modal.modal = null;
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
Drupal.CTools.Modal.currentSettings = settings;
|
64 |
|
|
|
65 |
|
|
var resize = function(e) {
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
var context = e ? document : Drupal.CTools.Modal.modal;
|
70 |
|
|
|
71 |
|
|
if (Drupal.CTools.Modal.currentSettings.modalSize.type == 'scale') {
|
72 |
|
|
var width = $(window).width() * Drupal.CTools.Modal.currentSettings.modalSize.width;
|
73 |
|
|
var height = $(window).height() * Drupal.CTools.Modal.currentSettings.modalSize.height;
|
74 |
|
|
}
|
75 |
|
|
else {
|
76 |
|
|
var width = Drupal.CTools.Modal.currentSettings.modalSize.width;
|
77 |
|
|
var height = Drupal.CTools.Modal.currentSettings.modalSize.height;
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
$('div.ctools-modal-content', context).css({
|
82 |
|
|
'width': width + Drupal.CTools.Modal.currentSettings.modalSize.addWidth + 'px',
|
83 |
|
|
'height': height + Drupal.CTools.Modal.currentSettings.modalSize.addHeight + 'px'
|
84 |
|
|
});
|
85 |
|
|
$('div.ctools-modal-content .modal-content', context).css({
|
86 |
|
|
'width': (width - Drupal.CTools.Modal.currentSettings.modalSize.contentRight) + 'px',
|
87 |
|
|
'height': (height - Drupal.CTools.Modal.currentSettings.modalSize.contentBottom) + 'px'
|
88 |
|
|
});
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
if (!Drupal.CTools.Modal.modal) {
|
92 |
|
|
Drupal.CTools.Modal.modal = $(Drupal.theme(settings.modalTheme));
|
93 |
|
|
if (settings.modalSize.type == 'scale') {
|
94 |
|
|
$(window).bind('resize', resize);
|
95 |
|
|
}
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
resize();
|
99 |
|
|
|
100 |
|
|
$('span.modal-title', Drupal.CTools.Modal.modal).html(Drupal.CTools.Modal.currentSettings.loadingText);
|
101 |
560c3060
|
Julien Enselme
|
Drupal.CTools.Modal.modalContent(Drupal.CTools.Modal.modal, settings.modalOptions, settings.animation, settings.animationSpeed, settings.modalClass);
|
102 |
|
|
$('#modalContent .modal-content').html(Drupal.theme(settings.throbberTheme)).addClass('ctools-modal-loading');
|
103 |
3753f249
|
Assos Assos
|
|
104 |
|
|
|
105 |
|
|
$('#modalContent .modal-content').delegate('input.form-autocomplete', 'keyup', function() {
|
106 |
|
|
$('#autocomplete').css('top', $(this).position().top + $(this).outerHeight() + $(this).offsetParent().filter('#modal-content').scrollTop());
|
107 |
|
|
});
|
108 |
85ad3d82
|
Assos Assos
|
};
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
Drupal.CTools.Modal.dismiss = function() {
|
114 |
|
|
if (Drupal.CTools.Modal.modal) {
|
115 |
|
|
Drupal.CTools.Modal.unmodalContent(Drupal.CTools.Modal.modal);
|
116 |
|
|
}
|
117 |
|
|
};
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
Drupal.theme.prototype.CToolsModalDialog = function () {
|
123 |
|
|
var html = ''
|
124 |
|
|
html += ' <div id="ctools-modal">'
|
125 |
|
|
html += ' <div class="ctools-modal-content">'
|
126 |
|
|
html += ' <div class="modal-header">';
|
127 |
|
|
html += ' <a class="close" href="#">';
|
128 |
|
|
html += Drupal.CTools.Modal.currentSettings.closeText + Drupal.CTools.Modal.currentSettings.closeImage;
|
129 |
|
|
html += ' </a>';
|
130 |
|
|
html += ' <span id="modal-title" class="modal-title"> </span>';
|
131 |
|
|
html += ' </div>';
|
132 |
|
|
html += ' <div id="modal-content" class="modal-content">';
|
133 |
|
|
html += ' </div>';
|
134 |
|
|
html += ' </div>';
|
135 |
|
|
html += ' </div>';
|
136 |
|
|
|
137 |
|
|
return html;
|
138 |
|
|
}
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
Drupal.theme.prototype.CToolsModalThrobber = function () {
|
144 |
|
|
var html = '';
|
145 |
|
|
html += ' <div id="modal-throbber">';
|
146 |
|
|
html += ' <div class="modal-throbber-wrapper">';
|
147 |
|
|
html += Drupal.CTools.Modal.currentSettings.throbber;
|
148 |
|
|
html += ' </div>';
|
149 |
|
|
html += ' </div>';
|
150 |
|
|
|
151 |
|
|
return html;
|
152 |
|
|
};
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
Drupal.CTools.Modal.getSettings = function (object) {
|
158 |
|
|
var match = $(object).attr('class').match(/ctools-modal-(\S+)/);
|
159 |
|
|
if (match) {
|
160 |
|
|
return match[1];
|
161 |
|
|
}
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
Drupal.CTools.Modal.clickAjaxCacheLink = function () {
|
168 |
|
|
Drupal.CTools.Modal.show(Drupal.CTools.Modal.getSettings(this));
|
169 |
|
|
return Drupal.CTools.AJAX.clickAJAXCacheLink.apply(this);
|
170 |
|
|
};
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
Drupal.CTools.Modal.clickAjaxLink = function () {
|
176 |
|
|
Drupal.CTools.Modal.show(Drupal.CTools.Modal.getSettings(this));
|
177 |
|
|
return false;
|
178 |
|
|
};
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
Drupal.CTools.Modal.submitAjaxForm = function(e) {
|
184 |
|
|
var $form = $(this);
|
185 |
|
|
var url = $form.attr('action');
|
186 |
|
|
|
187 |
|
|
setTimeout(function() { Drupal.CTools.AJAX.ajaxSubmit($form, url); }, 1);
|
188 |
|
|
return false;
|
189 |
|
|
}
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
Drupal.behaviors.ZZCToolsModal = {
|
195 |
|
|
attach: function(context) {
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
$('area.ctools-use-modal, a.ctools-use-modal', context).once('ctools-use-modal', function() {
|
208 |
|
|
var $this = $(this);
|
209 |
|
|
$this.click(Drupal.CTools.Modal.clickAjaxLink);
|
210 |
|
|
|
211 |
|
|
var element_settings = {};
|
212 |
|
|
if ($this.attr('href')) {
|
213 |
|
|
element_settings.url = $this.attr('href');
|
214 |
|
|
element_settings.event = 'click';
|
215 |
|
|
element_settings.progress = { type: 'throbber' };
|
216 |
|
|
}
|
217 |
|
|
var base = $this.attr('href');
|
218 |
|
|
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
|
219 |
|
|
});
|
220 |
|
|
|
221 |
|
|
|
222 |
|
|
$('input.ctools-use-modal, button.ctools-use-modal', context).once('ctools-use-modal', function() {
|
223 |
|
|
var $this = $(this);
|
224 |
|
|
$this.click(Drupal.CTools.Modal.clickAjaxLink);
|
225 |
|
|
var button = this;
|
226 |
|
|
var element_settings = {};
|
227 |
|
|
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
element_settings.url = Drupal.CTools.Modal.findURL(this);
|
231 |
3753f249
|
Assos Assos
|
if (element_settings.url == '') {
|
232 |
|
|
element_settings.url = $(this).closest('form').attr('action');
|
233 |
|
|
}
|
234 |
85ad3d82
|
Assos Assos
|
element_settings.event = 'click';
|
235 |
3753f249
|
Assos Assos
|
element_settings.setClick = true;
|
236 |
85ad3d82
|
Assos Assos
|
|
237 |
|
|
var base = $this.attr('id');
|
238 |
|
|
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
|
239 |
|
|
|
240 |
|
|
|
241 |
|
|
$('.' + $(button).attr('id') + '-url').change(function() {
|
242 |
|
|
Drupal.ajax[base].options.url = Drupal.CTools.Modal.findURL(button);
|
243 |
|
|
});
|
244 |
|
|
});
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
$('#modal-content form', context).once('ctools-use-modal', function() {
|
248 |
|
|
var $this = $(this);
|
249 |
|
|
var element_settings = {};
|
250 |
|
|
|
251 |
|
|
element_settings.url = $this.attr('action');
|
252 |
|
|
element_settings.event = 'submit';
|
253 |
|
|
element_settings.progress = { 'type': 'throbber' }
|
254 |
|
|
var base = $this.attr('id');
|
255 |
|
|
|
256 |
|
|
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
|
257 |
|
|
Drupal.ajax[base].form = $this;
|
258 |
|
|
|
259 |
|
|
$('input[type=submit], button', this).click(function(event) {
|
260 |
|
|
Drupal.ajax[base].element = this;
|
261 |
|
|
this.form.clk = this;
|
262 |
96a203dd
|
Assos Assos
|
|
263 |
|
|
if (Drupal.autocompleteSubmit && !Drupal.autocompleteSubmit()) {
|
264 |
|
|
return false;
|
265 |
|
|
}
|
266 |
85ad3d82
|
Assos Assos
|
|
267 |
|
|
|
268 |
|
|
if (event.bubbles == undefined) {
|
269 |
|
|
$(this.form).trigger('submit');
|
270 |
|
|
return false;
|
271 |
|
|
}
|
272 |
|
|
});
|
273 |
|
|
});
|
274 |
|
|
|
275 |
|
|
|
276 |
|
|
|
277 |
|
|
$('.ctools-close-modal', context).once('ctools-close-modal')
|
278 |
|
|
.click(function() {
|
279 |
|
|
Drupal.CTools.Modal.dismiss();
|
280 |
|
|
return false;
|
281 |
|
|
});
|
282 |
|
|
}
|
283 |
|
|
};
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
|
287 |
|
|
|
288 |
|
|
|
289 |
|
|
|
290 |
|
|
Drupal.CTools.Modal.modal_display = function(ajax, response, status) {
|
291 |
|
|
if ($('#modalContent').length == 0) {
|
292 |
|
|
Drupal.CTools.Modal.show(Drupal.CTools.Modal.getSettings(ajax.element));
|
293 |
|
|
}
|
294 |
|
|
$('#modal-title').html(response.title);
|
295 |
|
|
|
296 |
|
|
|
297 |
|
|
|
298 |
|
|
$('#modal-content').html(response.output).scrollTop(0);
|
299 |
3753f249
|
Assos Assos
|
|
300 |
|
|
|
301 |
|
|
var settings = response.settings || ajax.settings || Drupal.settings;
|
302 |
|
|
Drupal.attachBehaviors('#modalContent', settings);
|
303 |
560c3060
|
Julien Enselme
|
|
304 |
|
|
if ($('#modal-content').hasClass('ctools-modal-loading')) {
|
305 |
|
|
$('#modal-content').removeClass('ctools-modal-loading');
|
306 |
|
|
}
|
307 |
|
|
else {
|
308 |
|
|
|
309 |
|
|
|
310 |
|
|
|
311 |
|
|
|
312 |
|
|
$('#modal-content :focusable:first').focus();
|
313 |
|
|
}
|
314 |
85ad3d82
|
Assos Assos
|
}
|
315 |
|
|
|
316 |
|
|
|
317 |
|
|
|
318 |
|
|
|
319 |
|
|
Drupal.CTools.Modal.modal_dismiss = function(command) {
|
320 |
|
|
Drupal.CTools.Modal.dismiss();
|
321 |
|
|
$('link.ctools-temporary-css').remove();
|
322 |
|
|
}
|
323 |
|
|
|
324 |
|
|
|
325 |
|
|
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
Drupal.CTools.Modal.modal_loading = function(command) {
|
329 |
|
|
Drupal.CTools.Modal.modal_display({
|
330 |
|
|
output: Drupal.theme(Drupal.CTools.Modal.currentSettings.throbberTheme),
|
331 |
|
|
title: Drupal.CTools.Modal.currentSettings.loadingText
|
332 |
|
|
});
|
333 |
|
|
}
|
334 |
|
|
|
335 |
|
|
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
|
341 |
|
|
|
342 |
|
|
|
343 |
|
|
Drupal.CTools.Modal.findURL = function(item) {
|
344 |
|
|
var url = '';
|
345 |
|
|
var url_class = '.' + $(item).attr('id') + '-url';
|
346 |
|
|
$(url_class).each(
|
347 |
|
|
function() {
|
348 |
|
|
var $this = $(this);
|
349 |
|
|
if (url && $this.val()) {
|
350 |
|
|
url += '/';
|
351 |
|
|
}
|
352 |
|
|
url += $this.val();
|
353 |
|
|
});
|
354 |
|
|
return url;
|
355 |
|
|
};
|
356 |
|
|
|
357 |
|
|
|
358 |
|
|
|
359 |
|
|
|
360 |
|
|
|
361 |
|
|
|
362 |
|
|
|
363 |
|
|
|
364 |
560c3060
|
Julien Enselme
|
|
365 |
85ad3d82
|
Assos Assos
|
|
366 |
560c3060
|
Julien Enselme
|
Drupal.CTools.Modal.modalContent = function(content, css, animation, speed, modalClass) {
|
367 |
85ad3d82
|
Assos Assos
|
|
368 |
|
|
if (!animation) {
|
369 |
|
|
animation = 'show';
|
370 |
|
|
}
|
371 |
|
|
else {
|
372 |
|
|
|
373 |
|
|
if (animation != 'fadeIn' && animation != 'slideDown') {
|
374 |
|
|
animation = 'show';
|
375 |
|
|
}
|
376 |
|
|
}
|
377 |
|
|
|
378 |
|
|
if (!speed) {
|
379 |
|
|
speed = 'fast';
|
380 |
|
|
}
|
381 |
|
|
|
382 |
|
|
|
383 |
|
|
css = jQuery.extend({
|
384 |
|
|
position: 'absolute',
|
385 |
|
|
left: '0px',
|
386 |
|
|
margin: '0px',
|
387 |
|
|
background: '#000',
|
388 |
|
|
opacity: '.55'
|
389 |
|
|
}, css);
|
390 |
|
|
|
391 |
|
|
|
392 |
|
|
css.filter = 'alpha(opacity=' + (100 * css.opacity) + ')';
|
393 |
|
|
content.hide();
|
394 |
|
|
|
395 |
e4c061ad
|
Assos Assos
|
|
396 |
|
|
if ($('#modalBackdrop').length) $('#modalBackdrop').remove();
|
397 |
|
|
if ($('#modalContent').length) $('#modalContent').remove();
|
398 |
85ad3d82
|
Assos Assos
|
|
399 |
|
|
|
400 |
|
|
if (self.pageYOffset) {
|
401 |
|
|
var wt = self.pageYOffset;
|
402 |
|
|
} else if (document.documentElement && document.documentElement.scrollTop) {
|
403 |
|
|
var wt = document.documentElement.scrollTop;
|
404 |
|
|
} else if (document.body) {
|
405 |
|
|
var wt = document.body.scrollTop;
|
406 |
|
|
}
|
407 |
|
|
|
408 |
|
|
|
409 |
|
|
|
410 |
|
|
|
411 |
|
|
var docHeight = $(document).height() + 50;
|
412 |
|
|
var docWidth = $(document).width();
|
413 |
|
|
var winHeight = $(window).height();
|
414 |
|
|
var winWidth = $(window).width();
|
415 |
|
|
if( docHeight < winHeight ) docHeight = winHeight;
|
416 |
|
|
|
417 |
|
|
|
418 |
560c3060
|
Julien Enselme
|
$('body').append('<div id="modalBackdrop" class="backdrop-' + modalClass + '" style="z-index: 1000; display: none;"></div><div id="modalContent" class="modal-' + modalClass + '" style="z-index: 1001; position: absolute;">' + $(content).html() + '</div>');
|
419 |
|
|
|
420 |
|
|
|
421 |
|
|
var getTabbableElements = function () {
|
422 |
|
|
var tabbableElements = $('#modalContent :tabbable'),
|
423 |
|
|
radioButtons = tabbableElements.filter('input[type="radio"]');
|
424 |
|
|
|
425 |
|
|
|
426 |
|
|
|
427 |
|
|
|
428 |
|
|
|
429 |
|
|
|
430 |
|
|
if (radioButtons.length > 0) {
|
431 |
|
|
|
432 |
|
|
var anySelected = {};
|
433 |
|
|
radioButtons.each(function () {
|
434 |
|
|
var name = this.name;
|
435 |
|
|
|
436 |
|
|
if (typeof anySelected[name] === 'undefined') {
|
437 |
|
|
anySelected[name] = radioButtons.filter('input[name="' + name + '"]:checked').length !== 0;
|
438 |
|
|
}
|
439 |
|
|
});
|
440 |
|
|
|
441 |
|
|
|
442 |
|
|
var found = {};
|
443 |
|
|
tabbableElements = tabbableElements.filter(function () {
|
444 |
|
|
var keep = true;
|
445 |
|
|
|
446 |
|
|
if (this.type == 'radio') {
|
447 |
|
|
if (anySelected[this.name]) {
|
448 |
|
|
|
449 |
|
|
keep = this.checked;
|
450 |
|
|
}
|
451 |
|
|
else {
|
452 |
|
|
|
453 |
|
|
if (found[this.name]) {
|
454 |
|
|
keep = false;
|
455 |
|
|
}
|
456 |
|
|
found[this.name] = true;
|
457 |
|
|
}
|
458 |
|
|
}
|
459 |
85ad3d82
|
Assos Assos
|
|
460 |
560c3060
|
Julien Enselme
|
return keep;
|
461 |
|
|
});
|
462 |
|
|
}
|
463 |
|
|
|
464 |
|
|
return tabbableElements.get();
|
465 |
|
|
};
|
466 |
|
|
|
467 |
|
|
|
468 |
85ad3d82
|
Assos Assos
|
modalEventHandler = function( event ) {
|
469 |
|
|
target = null;
|
470 |
|
|
if ( event ) {
|
471 |
|
|
target = event.target;
|
472 |
|
|
} else {
|
473 |
|
|
event = window.event;
|
474 |
|
|
target = event.srcElement;
|
475 |
|
|
}
|
476 |
|
|
|
477 |
|
|
var parents = $(target).parents().get();
|
478 |
|
|
for (var i = 0; i < parents.length; ++i) {
|
479 |
|
|
var position = $(parents[i]).css('position');
|
480 |
|
|
if (position == 'absolute' || position == 'fixed') {
|
481 |
|
|
return true;
|
482 |
|
|
}
|
483 |
|
|
}
|
484 |
e4c061ad
|
Assos Assos
|
|
485 |
|
|
if ($(target).is('#modalContent, body') || $(target).filter('*:visible').parents('#modalContent').length) {
|
486 |
|
|
|
487 |
|
|
|
488 |
85ad3d82
|
Assos Assos
|
return true;
|
489 |
|
|
}
|
490 |
e4c061ad
|
Assos Assos
|
else {
|
491 |
560c3060
|
Julien Enselme
|
getTabbableElements()[0].focus();
|
492 |
e4c061ad
|
Assos Assos
|
}
|
493 |
|
|
|
494 |
|
|
event.preventDefault();
|
495 |
85ad3d82
|
Assos Assos
|
};
|
496 |
|
|
$('body').bind( 'focus', modalEventHandler );
|
497 |
|
|
$('body').bind( 'keypress', modalEventHandler );
|
498 |
|
|
|
499 |
560c3060
|
Julien Enselme
|
|
500 |
|
|
|
501 |
|
|
|
502 |
|
|
modalTabTrapHandler = function (evt) {
|
503 |
|
|
|
504 |
|
|
if (evt.which != 9) {
|
505 |
|
|
return true;
|
506 |
|
|
}
|
507 |
|
|
|
508 |
|
|
var tabbableElements = getTabbableElements(),
|
509 |
|
|
firstTabbableElement = tabbableElements[0],
|
510 |
|
|
lastTabbableElement = tabbableElements[tabbableElements.length - 1],
|
511 |
|
|
singleTabbableElement = firstTabbableElement == lastTabbableElement,
|
512 |
|
|
node = evt.target;
|
513 |
|
|
|
514 |
|
|
|
515 |
|
|
|
516 |
|
|
if (node == firstTabbableElement && evt.shiftKey) {
|
517 |
|
|
if (!singleTabbableElement) {
|
518 |
|
|
lastTabbableElement.focus();
|
519 |
|
|
}
|
520 |
|
|
return false;
|
521 |
|
|
}
|
522 |
|
|
|
523 |
|
|
|
524 |
|
|
else if (node == lastTabbableElement && !evt.shiftKey) {
|
525 |
|
|
if (!singleTabbableElement) {
|
526 |
|
|
firstTabbableElement.focus();
|
527 |
|
|
}
|
528 |
|
|
return false;
|
529 |
|
|
}
|
530 |
|
|
|
531 |
|
|
|
532 |
|
|
else if ($.inArray(node, tabbableElements) == -1) {
|
533 |
|
|
|
534 |
|
|
var parents = $(node).parents().get();
|
535 |
|
|
for (var i = 0; i < parents.length; ++i) {
|
536 |
|
|
var position = $(parents[i]).css('position');
|
537 |
|
|
if (position == 'absolute' || position == 'fixed') {
|
538 |
|
|
return true;
|
539 |
|
|
}
|
540 |
|
|
}
|
541 |
|
|
|
542 |
|
|
if (evt.shiftKey) {
|
543 |
|
|
lastTabbableElement.focus();
|
544 |
|
|
}
|
545 |
|
|
else {
|
546 |
|
|
firstTabbableElement.focus();
|
547 |
|
|
}
|
548 |
|
|
}
|
549 |
|
|
};
|
550 |
|
|
$('body').bind('keydown', modalTabTrapHandler);
|
551 |
|
|
|
552 |
85ad3d82
|
Assos Assos
|
|
553 |
|
|
var modalContent = $('#modalContent').css('top','-1000px');
|
554 |
|
|
var mdcTop = wt + ( winHeight / 2 ) - ( modalContent.outerHeight() / 2);
|
555 |
|
|
var mdcLeft = ( winWidth / 2 ) - ( modalContent.outerWidth() / 2);
|
556 |
|
|
$('#modalBackdrop').css(css).css('top', 0).css('height', docHeight + 'px').css('width', docWidth + 'px').show();
|
557 |
|
|
modalContent.css({top: mdcTop + 'px', left: mdcLeft + 'px'}).hide()[animation](speed);
|
558 |
|
|
|
559 |
|
|
|
560 |
|
|
modalContentClose = function(){close(); return false;};
|
561 |
|
|
$('.close').bind('click', modalContentClose);
|
562 |
|
|
|
563 |
|
|
|
564 |
|
|
modalEventEscapeCloseHandler = function(event) {
|
565 |
|
|
if (event.keyCode == 27) {
|
566 |
|
|
close();
|
567 |
|
|
return false;
|
568 |
|
|
}
|
569 |
|
|
};
|
570 |
|
|
|
571 |
|
|
$(document).bind('keydown', modalEventEscapeCloseHandler);
|
572 |
|
|
|
573 |
560c3060
|
Julien Enselme
|
|
574 |
|
|
|
575 |
|
|
|
576 |
|
|
var oldFocus = document.activeElement;
|
577 |
|
|
$('.close').focus();
|
578 |
|
|
|
579 |
85ad3d82
|
Assos Assos
|
|
580 |
|
|
function close() {
|
581 |
|
|
|
582 |
|
|
$(window).unbind('resize', modalContentResize);
|
583 |
|
|
$('body').unbind( 'focus', modalEventHandler);
|
584 |
|
|
$('body').unbind( 'keypress', modalEventHandler );
|
585 |
560c3060
|
Julien Enselme
|
$('body').unbind( 'keydown', modalTabTrapHandler );
|
586 |
85ad3d82
|
Assos Assos
|
$('.close').unbind('click', modalContentClose);
|
587 |
|
|
$('body').unbind('keypress', modalEventEscapeCloseHandler);
|
588 |
|
|
$(document).trigger('CToolsDetachBehaviors', $('#modalContent'));
|
589 |
|
|
|
590 |
|
|
|
591 |
|
|
if ( animation == 'fadeIn' ) animation = 'fadeOut';
|
592 |
|
|
if ( animation == 'slideDown' ) animation = 'slideUp';
|
593 |
|
|
if ( animation == 'show' ) animation = 'hide';
|
594 |
|
|
|
595 |
|
|
|
596 |
|
|
modalContent.hide()[animation](speed);
|
597 |
|
|
|
598 |
|
|
|
599 |
|
|
$('#modalContent').remove();
|
600 |
|
|
$('#modalBackdrop').remove();
|
601 |
560c3060
|
Julien Enselme
|
|
602 |
|
|
|
603 |
|
|
$(oldFocus).focus();
|
604 |
85ad3d82
|
Assos Assos
|
};
|
605 |
|
|
|
606 |
560c3060
|
Julien Enselme
|
|
607 |
|
|
modalContentResize = function(){
|
608 |
e4c061ad
|
Assos Assos
|
|
609 |
560c3060
|
Julien Enselme
|
|
610 |
|
|
$('#modalBackdrop').css('height', '').css('width', '');
|
611 |
|
|
|
612 |
|
|
|
613 |
|
|
|
614 |
e4c061ad
|
Assos Assos
|
if (self.pageYOffset) {
|
615 |
|
|
var wt = self.pageYOffset;
|
616 |
|
|
} else if (document.documentElement && document.documentElement.scrollTop) {
|
617 |
|
|
var wt = document.documentElement.scrollTop;
|
618 |
|
|
} else if (document.body) {
|
619 |
|
|
var wt = document.body.scrollTop;
|
620 |
|
|
}
|
621 |
|
|
|
622 |
85ad3d82
|
Assos Assos
|
|
623 |
|
|
var docHeight = $(document).height();
|
624 |
|
|
var docWidth = $(document).width();
|
625 |
|
|
var winHeight = $(window).height();
|
626 |
|
|
var winWidth = $(window).width();
|
627 |
|
|
if( docHeight < winHeight ) docHeight = winHeight;
|
628 |
|
|
|
629 |
|
|
|
630 |
|
|
var modalContent = $('#modalContent');
|
631 |
e4c061ad
|
Assos Assos
|
var mdcTop = wt + ( winHeight / 2 ) - ( modalContent.outerHeight() / 2);
|
632 |
85ad3d82
|
Assos Assos
|
var mdcLeft = ( winWidth / 2 ) - ( modalContent.outerWidth() / 2);
|
633 |
|
|
|
634 |
|
|
|
635 |
|
|
$('#modalBackdrop').css('height', docHeight + 'px').css('width', docWidth + 'px').show();
|
636 |
|
|
modalContent.css('top', mdcTop + 'px').css('left', mdcLeft + 'px').show();
|
637 |
|
|
};
|
638 |
|
|
$(window).bind('resize', modalContentResize);
|
639 |
|
|
};
|
640 |
|
|
|
641 |
|
|
|
642 |
|
|
|
643 |
|
|
|
644 |
|
|
|
645 |
|
|
|
646 |
|
|
|
647 |
|
|
Drupal.CTools.Modal.unmodalContent = function(content, animation, speed)
|
648 |
|
|
{
|
649 |
|
|
|
650 |
|
|
if (!animation) { var animation = 'show'; } else {
|
651 |
|
|
|
652 |
|
|
if (( animation != 'fadeOut' ) && ( animation != 'slideUp')) animation = 'show';
|
653 |
|
|
}
|
654 |
|
|
|
655 |
|
|
if ( !speed ) var speed = 'fast';
|
656 |
|
|
|
657 |
|
|
|
658 |
|
|
$(window).unbind('resize', modalContentResize);
|
659 |
|
|
$('body').unbind('focus', modalEventHandler);
|
660 |
|
|
$('body').unbind('keypress', modalEventHandler);
|
661 |
560c3060
|
Julien Enselme
|
$('body').unbind( 'keydown', modalTabTrapHandler );
|
662 |
85ad3d82
|
Assos Assos
|
$('.close').unbind('click', modalContentClose);
|
663 |
560c3060
|
Julien Enselme
|
$('body').unbind('keypress', modalEventEscapeCloseHandler);
|
664 |
85ad3d82
|
Assos Assos
|
$(document).trigger('CToolsDetachBehaviors', $('#modalContent'));
|
665 |
|
|
|
666 |
|
|
|
667 |
|
|
content.each(function(){
|
668 |
|
|
if ( animation == 'fade' ) {
|
669 |
|
|
$('#modalContent').fadeOut(speed, function() {
|
670 |
|
|
$('#modalBackdrop').fadeOut(speed, function() {
|
671 |
|
|
$(this).remove();
|
672 |
|
|
});
|
673 |
|
|
$(this).remove();
|
674 |
|
|
});
|
675 |
|
|
} else {
|
676 |
|
|
if ( animation == 'slide' ) {
|
677 |
|
|
$('#modalContent').slideUp(speed,function() {
|
678 |
|
|
$('#modalBackdrop').slideUp(speed, function() {
|
679 |
|
|
$(this).remove();
|
680 |
|
|
});
|
681 |
|
|
$(this).remove();
|
682 |
|
|
});
|
683 |
|
|
} else {
|
684 |
|
|
$('#modalContent').remove();
|
685 |
|
|
$('#modalBackdrop').remove();
|
686 |
|
|
}
|
687 |
|
|
}
|
688 |
|
|
});
|
689 |
|
|
};
|
690 |
|
|
|
691 |
|
|
$(function() {
|
692 |
|
|
Drupal.ajax.prototype.commands.modal_display = Drupal.CTools.Modal.modal_display;
|
693 |
|
|
Drupal.ajax.prototype.commands.modal_dismiss = Drupal.CTools.Modal.modal_dismiss;
|
694 |
|
|
});
|
695 |
|
|
|
696 |
|
|
})(jQuery); |