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') {
|
if ($plugin_page == 'comicpress/render_admin') {
|
||||||
wp_enqueue_style('cp-admin', get_stylesheet_directory_uri() . '/css/cp-admin.css');
|
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) {
|
if (strpos($pagenow, "media-upload") === 0) {
|
||||||
|
@ -315,7 +315,7 @@ class ComicPressAddonCore extends ComicPressAddon {
|
||||||
function _render_admin_storyline_tree($node, $parent_id = "0") {
|
function _render_admin_storyline_tree($node, $parent_id = "0") {
|
||||||
foreach ($node as $category_id => $children) {
|
foreach ($node as $category_id => $children) {
|
||||||
$category = get_category($category_id);
|
$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>';
|
echo '<span>' . $category->name . '</span>';
|
||||||
if (is_array($children)) {
|
if (is_array($children)) {
|
||||||
echo '<div class="cp-children">';
|
echo '<div class="cp-children">';
|
||||||
|
|
|
@ -2,24 +2,33 @@ var Storyline = {};
|
||||||
|
|
||||||
Storyline.get_order = function() {
|
Storyline.get_order = function() {
|
||||||
var order = []
|
var order = []
|
||||||
jQuery('#storyline-sorter .cp-category-info').each(function() {
|
$$('#storyline-sorter .cp-category-info').each(function(info) {
|
||||||
var matches = this.className.match(/category-([0-9\/]+)/);
|
var matches = info.id.match(/category_([0-9\/]+)/);
|
||||||
if (matches) { order.push(matches[1]); }
|
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() {
|
Storyline.setup = function() {
|
||||||
jQuery('.cp-children').sortable({
|
var i = 0;
|
||||||
handle: 'span',
|
var depths = {};
|
||||||
cursor: 'move',
|
$$('#storyline-sorter .cp-children').each(function(ch) {
|
||||||
placeholder: 'placeholder',
|
ch.id = 'children-' + i;
|
||||||
forcePlaceholderSize: true,
|
var depth = ch.ancestors().length;
|
||||||
opacity: 0.4,
|
if (!depths[depth]) { depths[depth] = []; }
|
||||||
stop: function(e, ui) {
|
depths[depth].push(ch);
|
||||||
Storyline.get_order();
|
++i;
|
||||||
}
|
});
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
jQuery(function() { Storyline.get_order(); });
|
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
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue