Révision 6e3ce7c2
Ajouté par Assos Assos il y a environ 3 ans
drupal7/sites/all/modules/ctools/js/modal.js | ||
---|---|---|
86 | 86 |
'width': (width - Drupal.CTools.Modal.currentSettings.modalSize.contentRight) + 'px', |
87 | 87 |
'height': (height - Drupal.CTools.Modal.currentSettings.modalSize.contentBottom) + 'px' |
88 | 88 |
}); |
89 |
} |
|
89 |
};
|
|
90 | 90 |
|
91 | 91 |
if (!Drupal.CTools.Modal.modal) { |
92 | 92 |
Drupal.CTools.Modal.modal = $(Drupal.theme(settings.modalTheme)); |
... | ... | |
120 | 120 |
* Provide the HTML to create the modal dialog. |
121 | 121 |
*/ |
122 | 122 |
Drupal.theme.prototype.CToolsModalDialog = function () { |
123 |
var html = '' |
|
124 |
html += '<div id="ctools-modal">' |
|
125 |
html += ' <div class="ctools-modal-content">' // panels-modal-content |
|
123 |
var html = '';
|
|
124 |
html += '<div id="ctools-modal">';
|
|
125 |
html += ' <div class="ctools-modal-content">'; // panels-modal-content
|
|
126 | 126 |
html += ' <div class="modal-header">'; |
127 | 127 |
html += ' <a class="close" href="#">'; |
128 | 128 |
html += Drupal.CTools.Modal.currentSettings.closeText + Drupal.CTools.Modal.currentSettings.closeImage; |
... | ... | |
135 | 135 |
html += '</div>'; |
136 | 136 |
|
137 | 137 |
return html; |
138 |
} |
|
138 |
};
|
|
139 | 139 |
|
140 | 140 |
/** |
141 | 141 |
* Provide the HTML to create the throbber. |
... | ... | |
159 | 159 |
if (match) { |
160 | 160 |
return match[1]; |
161 | 161 |
} |
162 |
} |
|
162 |
};
|
|
163 | 163 |
|
164 | 164 |
/** |
165 | 165 |
* Click function for modals that can be cached. |
... | ... | |
186 | 186 |
|
187 | 187 |
setTimeout(function() { Drupal.CTools.AJAX.ajaxSubmit($form, url); }, 1); |
188 | 188 |
return false; |
189 |
} |
|
189 |
};
|
|
190 | 190 |
|
191 | 191 |
/** |
192 | 192 |
* Bind links that will open modals to the appropriate function. |
... | ... | |
250 | 250 |
|
251 | 251 |
element_settings.url = $this.attr('action'); |
252 | 252 |
element_settings.event = 'submit'; |
253 |
element_settings.progress = { 'type': 'throbber' } |
|
253 |
element_settings.progress = { 'type': 'throbber' };
|
|
254 | 254 |
var base = $this.attr('id'); |
255 | 255 |
|
256 | 256 |
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); |
... | ... | |
291 | 291 |
* AJAX responder command to place HTML within the modal. |
292 | 292 |
*/ |
293 | 293 |
Drupal.CTools.Modal.modal_display = function(ajax, response, status) { |
294 |
var settings = response.settings || ajax.settings || Drupal.settings; |
|
295 |
// If the modal does not exist yet, create it. |
|
294 | 296 |
if ($('#modalContent').length == 0) { |
295 | 297 |
Drupal.CTools.Modal.show(Drupal.CTools.Modal.getSettings(ajax.element)); |
296 | 298 |
} |
299 |
// If the modal exists run detachBehaviors before removing existing content. |
|
300 |
else { |
|
301 |
Drupal.detachBehaviors($('#modalContent'), settings, 'unload'); |
|
302 |
} |
|
297 | 303 |
$('#modal-title').html(response.title); |
298 | 304 |
// Simulate an actual page load by scrolling to the top after adding the |
299 | 305 |
// content. This is helpful for allowing users to see error messages at the |
... | ... | |
302 | 308 |
$(document).trigger('CToolsAttachBehaviors', $('#modalContent')); |
303 | 309 |
|
304 | 310 |
// Attach behaviors within a modal dialog. |
305 |
var settings = response.settings || ajax.settings || Drupal.settings; |
|
306 | 311 |
Drupal.attachBehaviors($('#modalContent'), settings); |
307 | 312 |
|
308 | 313 |
if ($('#modal-content').hasClass('ctools-modal-loading')) { |
... | ... | |
315 | 320 |
// button by the show() function called above.) |
316 | 321 |
$('#modal-content :focusable:first').focus(); |
317 | 322 |
} |
318 |
} |
|
323 |
};
|
|
319 | 324 |
|
320 | 325 |
/** |
321 | 326 |
* AJAX responder command to dismiss the modal. |
... | ... | |
323 | 328 |
Drupal.CTools.Modal.modal_dismiss = function(command) { |
324 | 329 |
Drupal.CTools.Modal.dismiss(); |
325 | 330 |
$('link.ctools-temporary-css').remove(); |
326 |
} |
|
331 |
};
|
|
327 | 332 |
|
328 | 333 |
/** |
329 | 334 |
* Display loading |
... | ... | |
334 | 339 |
output: Drupal.theme(Drupal.CTools.Modal.currentSettings.throbberTheme), |
335 | 340 |
title: Drupal.CTools.Modal.currentSettings.loadingText |
336 | 341 |
}); |
337 |
} |
|
342 |
};
|
|
338 | 343 |
|
339 | 344 |
/** |
340 | 345 |
* Find a URL for an AJAX button. |
... | ... | |
590 | 595 |
$('body').unbind( 'keydown', modalTabTrapHandler ); |
591 | 596 |
$('.close', $modalHeader).unbind('click', modalContentClose); |
592 | 597 |
$(document).unbind('keydown', modalEventEscapeCloseHandler); |
598 |
$(document).trigger('CToolsCloseModalBehaviors', $('#modalContent')); |
|
593 | 599 |
$(document).trigger('CToolsDetachBehaviors', $('#modalContent')); |
594 | 600 |
|
595 | 601 |
// Closing animation. |
... | ... | |
675 | 681 |
var $modalContent = $('#modalContent'); |
676 | 682 |
var $modalHeader = $modalContent.find('.modal-header'); |
677 | 683 |
$('.close', $modalHeader).unbind('click', modalContentClose); |
678 |
$('body').unbind('keypress', modalEventEscapeCloseHandler);
|
|
684 |
$(document).unbind('keydown', modalEventEscapeCloseHandler);
|
|
679 | 685 |
$(document).trigger('CToolsDetachBehaviors', $modalContent); |
680 | 686 |
|
681 | 687 |
// jQuery magic loop through the instances and run the animations or removal. |
Formats disponibles : Unified diff
Weekly update of contrib modules