|
|
|
@ -18,7 +18,8 @@ |
|
|
|
|
// See doc/COPYRIGHT.md for more details.
|
|
|
|
|
//++
|
|
|
|
|
|
|
|
|
|
/*globals jQuery, I18n*/ |
|
|
|
|
/* globals jQuery, $$, $, Sortable, Effect, Form */ |
|
|
|
|
/* jshint camelcase: false */ |
|
|
|
|
|
|
|
|
|
(function($) { |
|
|
|
|
// $ is prototype
|
|
|
|
@ -26,12 +27,12 @@ |
|
|
|
|
|
|
|
|
|
function recreateSortables() { |
|
|
|
|
var lists = $$('.list-position'), |
|
|
|
|
containedPositions = function() { |
|
|
|
|
containedPositions = (function() { |
|
|
|
|
var positions = _.map(lists, function(list) { |
|
|
|
|
return list.readAttribute('id') |
|
|
|
|
return list.readAttribute('id'); |
|
|
|
|
}); |
|
|
|
|
return _.uniq(positions); |
|
|
|
|
}(), |
|
|
|
|
}()), |
|
|
|
|
destroy = function destroy(list) { |
|
|
|
|
var id = list.readAttribute('id'); |
|
|
|
|
Sortable.destroy(id); |
|
|
|
@ -61,7 +62,7 @@ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function updateSelect() { |
|
|
|
|
s = $('block-select') |
|
|
|
|
var s = $('block-select'); |
|
|
|
|
for (var i = 0; i < s.options.length; i++) { |
|
|
|
|
if ($('block_' + s.options[i].value)) { |
|
|
|
|
s.options[i].disabled = true; |
|
|
|
@ -84,15 +85,15 @@ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function resetTextilizable(name) { |
|
|
|
|
$("textile_" + name).setValue(window["page_layout-textile" + name] + ""); |
|
|
|
|
$('textile_' + name).setValue(window['page_layout-textile' + name] + ''); |
|
|
|
|
toggleTextilizableVisibility(name); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function editTextilizable(name) { |
|
|
|
|
var textile_name = $("textile_" + name); |
|
|
|
|
if (textile_name != null) { |
|
|
|
|
window["page_layout-textile" + name] = textile_name.getValue(); |
|
|
|
|
var textile_name = $('textile_' + name); |
|
|
|
|
if (textile_name !== null) { |
|
|
|
|
window['page_layout-textile' + name] = textile_name.getValue(); |
|
|
|
|
toggleTextilizableVisibility(name); |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
@ -129,23 +130,52 @@ |
|
|
|
|
trigger: '.all', |
|
|
|
|
indicator_class: 'ajax-indicator', |
|
|
|
|
load_target: '#users_per_role', |
|
|
|
|
loading_text: I18n.t("js.ajax.loading"), |
|
|
|
|
loading_text: I18n.t('js.ajax.loading'), |
|
|
|
|
loading_class: 'box loading' |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// this was previously bound in the template directly
|
|
|
|
|
$('#block-select').on('change', addBlock); |
|
|
|
|
|
|
|
|
|
//initialize the fun!
|
|
|
|
|
// we need to rebind some of the links constantly, as the content is generated
|
|
|
|
|
// on the page
|
|
|
|
|
function updateBlockLinks() { |
|
|
|
|
function getBlockName(element) { |
|
|
|
|
var blockName = element.data('block-name'); |
|
|
|
|
if (!blockName) { |
|
|
|
|
throw new Error('no block name found for element'); |
|
|
|
|
} |
|
|
|
|
return blockName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// bind textilizable block links
|
|
|
|
|
$('a.reset-textilizable').on('click', function(e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
resetTextilizable(getBlockName($(this))); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('a.edit-textilizable').on('click', function(e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
editTextilizable(getBlockName($(this))); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// initialize the fun! (prototype)
|
|
|
|
|
recreateSortables(); |
|
|
|
|
updateSelect(); |
|
|
|
|
|
|
|
|
|
// moar fun
|
|
|
|
|
updateBlockLinks(); |
|
|
|
|
|
|
|
|
|
//these are generated blocks, so we have to watch the links inside them
|
|
|
|
|
|
|
|
|
|
// TODO: this is exceptionally _not_ fun
|
|
|
|
|
// this attaches the update method to the window in order for it
|
|
|
|
|
// being callable after removal
|
|
|
|
|
// being callable after removal of a block
|
|
|
|
|
window.myPage = window.myPage || { |
|
|
|
|
updateSelect: updateSelect |
|
|
|
|
updateSelect: updateSelect, |
|
|
|
|
updateBlockLinks: updateBlockLinks |
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
}(jQuery)) |
|
|
|
|
}(jQuery)); |
|
|
|
|
}($)); |
|
|
|
|