Révision 5a7e6170
Ajouté par Florent Torregrosa il y a environ 10 ans
drupal7/sites/all/modules/panels/panels_ipe/js/panels_ipe.js | ||
---|---|---|
15 | 15 |
$('a.pane-delete:not(.pane-delete-processed)', context) |
16 | 16 |
.addClass('pane-delete-processed') |
17 | 17 |
.click(function() { |
18 |
if (confirm('Remove this pane?')) {
|
|
18 |
if (confirm(Drupal.t('Remove this pane?'))) {
|
|
19 | 19 |
$(this).parents('div.panels-ipe-portlet-wrapper').fadeOut('medium', function() { |
20 |
var $sortable = $(this).closest('.ui-sortable'); |
|
20 | 21 |
$(this).empty().remove(); |
22 |
$sortable.trigger('sortremove'); |
|
21 | 23 |
}); |
22 | 24 |
$(this).parents('div.panels-ipe-display-container').addClass('changed'); |
23 | 25 |
} |
... | ... | |
34 | 36 |
$('div#panels-ipe-display-' + key + ':not(.panels-ipe-processed)') |
35 | 37 |
.addClass('panels-ipe-processed') |
36 | 38 |
.each(function() { |
39 |
// If we're replacing an old IPE, clean it up a little. |
|
40 |
if (Drupal.PanelsIPE.editors[key]) { |
|
41 |
Drupal.PanelsIPE.editors[key].editing = false; |
|
42 |
} |
|
37 | 43 |
Drupal.PanelsIPE.editors[key] = new DrupalPanelsIPE(key); |
38 | 44 |
Drupal.PanelsIPE.editors[key].showContainer(); |
39 | 45 |
}); |
... | ... | |
92 | 98 |
} |
93 | 99 |
}); |
94 | 100 |
|
101 |
|
|
102 |
// If a user navigates away from a locked IPE, cancel the lock in the background. |
|
103 |
$(window).bind('beforeunload', function() { |
|
104 |
if (!ipe.editing) { |
|
105 |
return; |
|
106 |
} |
|
107 |
|
|
108 |
if (ipe.topParent && ipe.topParent.hasClass('changed')) { |
|
109 |
ipe.changed = true; |
|
110 |
} |
|
111 |
|
|
112 |
if (ipe.changed) { |
|
113 |
return Drupal.t('This will discard all unsaved changes. Are you sure?'); |
|
114 |
} |
|
115 |
}); |
|
116 |
|
|
95 | 117 |
// If a user navigates away from a locked IPE, cancel the lock in the background. |
96 | 118 |
$(window).bind('unload', function() { |
97 | 119 |
ipe.cancelLock(true); |
... | ... | |
170 | 192 |
}; |
171 | 193 |
|
172 | 194 |
this.initEditing = function(formdata) { |
195 |
ipe.editing = true; |
|
173 | 196 |
ipe.topParent = $('div#panels-ipe-display-' + cache_key); |
174 | 197 |
ipe.backup = this.topParent.clone(); |
175 | 198 |
|
... | ... | |
212 | 235 |
ipe.showForm(); |
213 | 236 |
ipe.topParent.addClass('panels-ipe-editing'); |
214 | 237 |
|
215 |
//Reposition the "Add new pane" button |
|
216 |
$('.panels-ipe-newblock').each(function() { |
|
217 |
var link_width_half = parseInt($(this).children('a').outerWidth() / 2); |
|
218 |
|
|
219 |
$(this).css('margin-left', '-' + link_width_half + 'px'); |
|
220 |
|
|
221 |
$(this).css('margin-top', '-' + parseInt($(this).children('a').outerHeight() / 2) + 'px'); |
|
222 |
|
|
223 |
$(this).parents('.panels-ipe-placeholder').find('h3').css('width', parseInt(($(this).parents('.panels-ipe-placeholder').width() / 2) - link_width_half) + 'px'); |
|
224 |
}); |
|
225 |
|
|
226 | 238 |
}; |
227 | 239 |
|
228 | 240 |
this.hideContainer = function() { |
... | ... | |
246 | 258 |
}; |
247 | 259 |
|
248 | 260 |
this.endEditing = function() { |
261 |
ipe.editing = false; |
|
249 | 262 |
ipe.lockPath = null; |
250 |
$('.panels-ipe-form-container', ipe.control).empty();
|
|
263 |
$('.panels-ipe-form-container').empty(); |
|
251 | 264 |
// Re-show all the IPE non-editing meta-elements |
252 | 265 |
$('div.panels-ipe-off').show('fast'); |
253 | 266 |
|
254 | 267 |
ipe.showButtons(); |
255 | 268 |
// Re-hide all the IPE meta-elements |
256 | 269 |
$('div.panels-ipe-on').hide(); |
257 |
if (ipe.topParent) { |
|
258 |
ipe.topParent.removeClass('panels-ipe-editing'); |
|
259 |
$('div.panels-ipe-sort-container', ipe.topParent).sortable("destroy"); |
|
260 |
} |
|
270 |
|
|
271 |
$('.panels-ipe-editing').removeClass('panels-ipe-editing'); |
|
272 |
$('div.panels-ipe-sort-container.ui-sortable', ipe.topParent).sortable("destroy"); |
|
261 | 273 |
}; |
262 | 274 |
|
263 | 275 |
this.saveEditing = function() { |
... | ... | |
310 | 322 |
|
311 | 323 |
this.createSortContainers = function() { |
312 | 324 |
$('div.panels-ipe-region', this.topParent).each(function() { |
313 |
$('div.panels-ipe-portlet-marker', this).parent()
|
|
325 |
$(this).children('div.panels-ipe-portlet-marker').parent()
|
|
314 | 326 |
.wrapInner('<div class="panels-ipe-sort-container" />'); |
315 | 327 |
|
316 | 328 |
// Move our gadgets outside of the sort container so that sortables |
... | ... | |
318 | 330 |
$('div.panels-ipe-portlet-static', this).each(function() { |
319 | 331 |
$(this).prependTo($(this).parent().parent()); |
320 | 332 |
}); |
321 |
|
|
322 |
// Also remove the last panel separator. |
|
323 |
$('div.panel-separator', this).filter(':last').remove(); |
|
324 | 333 |
}); |
325 | 334 |
} |
326 | 335 |
|
... | ... | |
334 | 343 |
Drupal.PanelsIPE.editors[data.key].initEditing(data.data); |
335 | 344 |
Drupal.PanelsIPE.editors[data.key].lockPath = data.lockPath; |
336 | 345 |
} |
346 |
Drupal.attachBehaviors(); |
|
347 |
|
|
337 | 348 |
}; |
338 | 349 |
|
339 | 350 |
Drupal.ajax.prototype.commands.IPEsetLockState = function(ajax, data, status) { |
... | ... | |
342 | 353 |
} |
343 | 354 |
}; |
344 | 355 |
|
356 |
Drupal.ajax.prototype.commands.addNewPane = function(ajax, data, status) { |
|
357 |
if (Drupal.PanelsIPE.editors[data.key]) { |
|
358 |
Drupal.PanelsIPE.editors[data.key].changed = true; |
|
359 |
} |
|
360 |
}; |
|
361 |
|
|
345 | 362 |
Drupal.ajax.prototype.commands.cancelIPE = function(ajax, data, status) { |
346 | 363 |
if (Drupal.PanelsIPE.editors[data.key]) { |
347 | 364 |
Drupal.PanelsIPE.editors[data.key].cancelIPE(); |
... | ... | |
366 | 383 |
} |
367 | 384 |
}; |
368 | 385 |
|
386 |
Drupal.ajax.prototype.commands.insertNewPane = function(ajax, data, status) { |
|
387 |
IPEContainerSelector = '#panels-ipe-regionid-' + data.regionId + ' div.panels-ipe-sort-container'; |
|
388 |
firstPaneSelector = IPEContainerSelector + ' div.panels-ipe-portlet-wrapper:first'; |
|
389 |
// Insert the new pane before the first existing pane in the region, if |
|
390 |
// any. |
|
391 |
if ($(firstPaneSelector).length) { |
|
392 |
insertData = { |
|
393 |
'method': 'before', |
|
394 |
'selector': firstPaneSelector, |
|
395 |
'data': data.renderedPane, |
|
396 |
'settings': null |
|
397 |
} |
|
398 |
Drupal.ajax.prototype.commands.insert(ajax, insertData, status); |
|
399 |
} |
|
400 |
// Else, insert it as a first child of the container. Doing so might fall |
|
401 |
// outside of the wrapping markup for the style, but it's the best we can |
|
402 |
// do. |
|
403 |
else { |
|
404 |
insertData = { |
|
405 |
'method': 'prepend', |
|
406 |
'selector': IPEContainerSelector, |
|
407 |
'data': data.renderedPane, |
|
408 |
'settings': null |
|
409 |
} |
|
410 |
Drupal.ajax.prototype.commands.insert(ajax, insertData, status); |
|
411 |
} |
|
412 |
}; |
|
413 |
|
|
369 | 414 |
/** |
370 | 415 |
* Override the eventResponse on ajax.js so we can add a little extra |
371 | 416 |
* behavior. |
372 | 417 |
*/ |
373 | 418 |
Drupal.ajax.prototype.ipeReplacedEventResponse = Drupal.ajax.prototype.eventResponse; |
374 | 419 |
Drupal.ajax.prototype.eventResponse = function (element, event) { |
420 |
if (element.ipeCancelThis) { |
|
421 |
element.ipeCancelThis = null; |
|
422 |
return false; |
|
423 |
} |
|
424 |
|
|
375 | 425 |
if ($(this.element).attr('id') == 'panels-ipe-cancel') { |
376 | 426 |
if (!Drupal.PanelsIPE.editors[this.element_settings.ipe_cache_key].cancelEditing()) { |
377 | 427 |
return false; |
... | ... | |
404 | 454 |
|
405 | 455 |
Drupal.ajax.prototype.ipeReplacedBeforeSerialize = Drupal.ajax.prototype.beforeSerialize; |
406 | 456 |
Drupal.ajax.prototype.beforeSerialize = function (element_settings, options) { |
407 |
if ($(this.element).attr('id') == 'panels-ipe-save') {
|
|
457 |
if ($(this.element).hasClass('panels-ipe-save')) {
|
|
408 | 458 |
Drupal.PanelsIPE.editors[this.element_settings.ipe_cache_key].saveEditing(); |
409 | 459 |
}; |
410 | 460 |
return this.ipeReplacedBeforeSerialize(element_settings, options); |
Formats disponibles : Unified diff
Update :