switch to prototype
This commit is contained in:
parent
831b8d80c6
commit
5d66b8b589
|
@ -204,7 +204,7 @@ class ComicPressAddonCore extends ComicPressAddon {
|
|||
|
||||
if ($plugin_page == 'comicpress/render_admin') {
|
||||
wp_enqueue_style('cp-admin', get_stylesheet_directory_uri() . '/css/cp-admin.css');
|
||||
wp_enqueue_script('cp-admin', get_stylesheet_directory_uri() . '/js/Storyline.js', array('jquery', 'jquery-ui-sortable'));
|
||||
wp_enqueue_script('cp-admin', get_stylesheet_directory_uri() . '/js/Storyline.js', array('prototype', 'scriptaculous'));
|
||||
}
|
||||
|
||||
if (strpos($pagenow, "media-upload") === 0) {
|
||||
|
@ -315,7 +315,7 @@ class ComicPressAddonCore extends ComicPressAddon {
|
|||
function _render_admin_storyline_tree($node, $parent_id = "0") {
|
||||
foreach ($node as $category_id => $children) {
|
||||
$category = get_category($category_id);
|
||||
echo '<div class="cp-category-info category-' . $parent_id . '/' . $category_id . '">';
|
||||
echo '<div id="category_' . $parent_id . '/' . $category_id . '" class="cp-category-info">';
|
||||
echo '<span>' . $category->name . '</span>';
|
||||
if (is_array($children)) {
|
||||
echo '<div class="cp-children">';
|
||||
|
|
|
@ -2,24 +2,33 @@ var Storyline = {};
|
|||
|
||||
Storyline.get_order = function() {
|
||||
var order = []
|
||||
jQuery('#storyline-sorter .cp-category-info').each(function() {
|
||||
var matches = this.className.match(/category-([0-9\/]+)/);
|
||||
$$('#storyline-sorter .cp-category-info').each(function(info) {
|
||||
var matches = info.id.match(/category_([0-9\/]+)/);
|
||||
if (matches) { order.push(matches[1]); }
|
||||
});
|
||||
jQuery('input[name=cp[storyline_order]]').attr('value', order.join(','));
|
||||
$$('input[name*=storyline_order]').pop().value = order.join(',');
|
||||
};
|
||||
|
||||
Storyline.setup = function() {
|
||||
jQuery('.cp-children').sortable({
|
||||
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;
|
||||
});
|
||||
|
||||
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',
|
||||
cursor: 'move',
|
||||
placeholder: 'placeholder',
|
||||
forcePlaceholderSize: true,
|
||||
opacity: 0.4,
|
||||
stop: function(e, ui) {
|
||||
Storyline.get_order();
|
||||
}
|
||||
onUpdate: Storyline.get_order
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
jQuery(function() { Storyline.get_order(); });
|
Loading…
Reference in New Issue