| 1 |
// $Id: activemenu.js,v 1.1 2008/03/28 16:36:44 nedjo Exp $
|
| 2 |
|
| 3 |
Drupal.behaviors.activeEdit = function (context) {
|
| 4 |
$('body:not(.activeedit-processed)')
|
| 5 |
.addClass('activeedit-processed')
|
| 6 |
.prepend('<div class="activeedit-enable"><label><input class="activeedit-enable" type="checkbox" /> '+ Drupal.t('Active editing mode') +'</label></div>')
|
| 7 |
.find('input.activeedit-enable')
|
| 8 |
.click(function () {
|
| 9 |
var checked = $(this).is(':checked');
|
| 10 |
$.each(Drupal.settings.activeEdit, function (key, value) {
|
| 11 |
var delimiter = value['#url'].indexOf('?') == -1 ? '?' : '&';
|
| 12 |
$(value['#selector']).each(function () {
|
| 13 |
var a = document.createElement('a');
|
| 14 |
$(a)
|
| 15 |
.attr('href', value['#url'] + delimiter +'activeedit_element='+ key)
|
| 16 |
.addClass('activeedit');
|
| 17 |
if (checked) {
|
| 18 |
var link = $(this)
|
| 19 |
.wrap(a)
|
| 20 |
.mouseover(function() {
|
| 21 |
$(this).addClass('activeedit-active');
|
| 22 |
})
|
| 23 |
.mouseout(function() {
|
| 24 |
$(this).removeClass('activeedit-active');
|
| 25 |
})
|
| 26 |
.parent('a.activeedit')
|
| 27 |
.get(0);
|
| 28 |
Drupal.behaviors.popups(document);
|
| 29 |
}
|
| 30 |
else {
|
| 31 |
$(this)
|
| 32 |
.unbind('mouseover')
|
| 33 |
.unbind('mouseout')
|
| 34 |
.parent('a')
|
| 35 |
.replaceWith(this);
|
| 36 |
}
|
| 37 |
});
|
| 38 |
});
|
| 39 |
});
|
| 40 |
};
|