From 8954eec1443930ee6300f32bda83f8fa4b18d99d Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 13 Nov 2009 07:51:40 -0500 Subject: [PATCH] working on image types editor --- classes/ComicPressAdmin.inc | 1 + classes/partials/_image-type-editor.inc | 11 ++- classes/partials/options-admin.inc | 50 +----------- js/Storyline.js | 102 +++++++++++++++++------- 4 files changed, 85 insertions(+), 79 deletions(-) diff --git a/classes/ComicPressAdmin.inc b/classes/ComicPressAdmin.inc index a9b21e1..ac04a6c 100644 --- a/classes/ComicPressAdmin.inc +++ b/classes/ComicPressAdmin.inc @@ -79,6 +79,7 @@ class ComicPressAdmin { if ($plugin_page == 'comicpress/render_admin') { wp_enqueue_style('cp-admin', get_template_directory_uri() . '/css/cp-admin.css'); wp_enqueue_script('cp-admin', get_template_directory_uri() . '/js/Storyline.js', array('prototype', 'scriptaculous')); + add_action('admin_footer', array(&$this, 'admin_footer')); } if (strpos($pagenow, "-upload") !== false) { diff --git a/classes/partials/_image-type-editor.inc b/classes/partials/_image-type-editor.inc index 04a0569..f4d3572 100644 --- a/classes/partials/_image-type-editor.inc +++ b/classes/partials/_image-type-editor.inc @@ -1,5 +1,5 @@
- X + X @@ -11,7 +11,12 @@ - + @@ -19,6 +24,8 @@ x +
+ () diff --git a/classes/partials/options-admin.inc b/classes/partials/options-admin.inc index 96bed67..e343183 100644 --- a/classes/partials/options-admin.inc +++ b/classes/partials/options-admin.inc @@ -25,57 +25,11 @@ - Add a new image type + Add a new image type +
Name:
Default image type? /> + +
Dimensions
-

- - - - - - all_addons)) { ?> - - - - - -
- __('Show inline comic ordering', 'comicpress') - ) as $key => $label) { ?> - -
- -
- all_addons as $addon) { - if (!empty($addon->name)) { - $enabled = ($addon->is_addon_manager !== true); - $checked = $enabled && $this->comicpress->comicpress_options['addons'][$addon->name]; - ?> - -
- -
diff --git a/js/Storyline.js b/js/Storyline.js index 5c461f7..4b26337 100644 --- a/js/Storyline.js +++ b/js/Storyline.js @@ -1,34 +1,78 @@ var Storyline = {}; +var ComicImageTypes = {}; -Storyline.get_order = function() { - var order = [] - $$('#storyline-sorter .cp-category-info').each(function(info) { - var matches = info.id.match(/category_([0-9\/]+)/); - if (matches) { order.push(matches[1]); } - }); - $$('input[name*=storyline_order]').pop().value = order.join(','); -}; +(function() { + Storyline.get_order = function() { + var order = [] + $$('#storyline-sorter .cp-category-info').each(function(info) { + var matches = info.id.match(/category_([0-9\/]+)/); + if (matches) { order.push(matches[1]); } + }); + $$('input[name*=storyline_order]').pop().value = order.join(','); + }; -Storyline.setup = function() { - var i = 0; - var depths = {}; - $$('.cp-children').each(function(ch) { - ch.id = 'children-' + i; - var depth = ch.ancestors().length; - if (!depths[depth]) { depths[depth] = []; } - depths[depth].push(ch); - ++i; - }); + Storyline.setup = function() { + var i = 0; + var depths = {}; + $$('.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 = $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 - }); - }); - }); -}; + 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 + }); + }); + }); + }; + + ComicImageTypes.setup = function() { + $$('.image-type-holder').each(function(ith) { + var closer = ith.select('.delete-image-type').pop(); + if (closer) { + closer.observe('click', function(e) { + Event.stop(e); + if (confirm('Are you sure? Your templates may break after deleting this image type')) { + new Effect.Fade(ith, { + from: 1, + to: 0, + afterFinish: function() { + ith.parentNode.removeChild(ith); + } + }); + } + }); + } + }); + + var checkboxes = $$('input[name*=default][name*=image_types]'); + checkboxes.each(function(c) { + c.observe('change', function(e) { + checkboxes.each(function(ch) { + if (e.target != ch) { ch.checked = false; } + }); + }); + }); + + $('add-new-image-type').observe('click', function(e) { + Event.stop(e); + new Ajax.Updater('image-type-container', ComicPressAdmin.ajax_uri, { + method: 'get', + parameters: { + 'cp[_nonce]': ComicPressAdmin.nonce, + 'cp[ + }, + insertion: 'bottom' + }); + }); + }; +}())