comicpress-core/js/Storyline.js

35 lines
876 B
JavaScript
Raw Normal View History

2009-11-01 18:15:59 +00:00
var Storyline = {};
Storyline.get_order = function() {
var order = []
2009-11-03 03:21:53 +00:00
$$('#storyline-sorter .cp-category-info').each(function(info) {
var matches = info.id.match(/category_([0-9\/]+)/);
2009-11-01 18:15:59 +00:00
if (matches) { order.push(matches[1]); }
});
2009-11-03 03:21:53 +00:00
$$('input[name*=storyline_order]').pop().value = order.join(',');
2009-11-01 18:15:59 +00:00
};
Storyline.setup = function() {
2009-11-03 03:21:53 +00:00
var i = 0;
var depths = {};
$$('#storyline-sorter .cp-children').each(function(ch) {
ch.id = 'children-' + i;
var depth = ch.ancestors().length;
if (!depths[depth]) { depths[depth] = []; }
depths[depth].push(ch);
++i;
});
2009-11-01 18:15:59 +00:00
2009-11-03 03:21:53 +00:00
depths = $H(depths);
depths.keys().sort(function(a,b) { return b - a; }).each(function(depth) {
depths.get(depth).each(function(ch) {
Sortable.create(ch.id, {
tag: 'div',
handle: 'span',
onUpdate: Storyline.get_order
});
});
});
};