diff --git a/classes/ComicPressAdmin.inc b/classes/ComicPressAdmin.inc index e71e347..9b7d8b4 100644 --- a/classes/ComicPressAdmin.inc +++ b/classes/ComicPressAdmin.inc @@ -88,7 +88,7 @@ class ComicPressAdmin { switch ($plugin_page) { case 'comicpress/render_admin': wp_enqueue_style('cp-admin', plugin_dir_url(dirname(__FILE__)) . '/css/cp-admin.css'); - wp_enqueue_script('cp-admin', plugin_dir_url(dirname(__FILE__)) . '/js/Storyline.js', array('jquery', 'jquery-ui-dialog')); + wp_enqueue_script('cp-admin', plugin_dir_url(dirname(__FILE__)) . '/js/Storyline.js', array('jquery', 'jquery-ui-sortable', 'jquery-ui-tabs')); add_action('admin_footer', array(&$this, 'admin_footer')); break; case 'comicpress/comicpress_docs': @@ -375,14 +375,14 @@ class ComicPressAdmin { case 'image_types': if (is_array($info['image_types'])) { $this->comicpress->comicpress_options['image_types'] = array(); - $defined_default = null; + $defined_default = isset($info['image_types']['_default']) ? $info['image_types']['_default'] : null; + unset($info['image_types']['_default']); foreach ($info['image_types'] as $type => $image_info) { if (is_array($image_info)) { $new_value = array(); $new_type = $type; foreach ($image_info as $field => $field_value) { switch ($field) { - case 'default': $defined_default = $type; break; case 'dimensions': if (is_array($field_value)) { if (count(array_intersect(array('width', 'height'), array_keys($field_value))) == 2) { diff --git a/classes/partials/_comic-image-types.inc b/classes/partials/_comic-image-types.inc index 3f13266..4233c33 100644 --- a/classes/partials/_comic-image-types.inc +++ b/classes/partials/_comic-image-types.inc @@ -6,7 +6,6 @@ [+] Add a new image type - diff --git a/classes/partials/_image-type-editor.inc b/classes/partials/_image-type-editor.inc index 4ff358e..c4db801 100644 --- a/classes/partials/_image-type-editor.inc +++ b/classes/partials/_image-type-editor.inc @@ -13,7 +13,7 @@ Default image type? diff --git a/classes/partials/_storyline-order.inc b/classes/partials/_storyline-order.inc index ca09306..bd4b1f9 100644 --- a/classes/partials/_storyline-order.inc +++ b/classes/partials/_storyline-order.inc @@ -10,7 +10,6 @@ ?> -

Categories page)', 'comicpress') ?>

diff --git a/classes/partials/options-admin.inc b/classes/partials/options-admin.inc index 37b2e19..ff5c43f 100644 --- a/classes/partials/options-admin.inc +++ b/classes/partials/options-admin.inc @@ -5,95 +5,93 @@ - +
+ -

+

-
-
- comicpress->comicpress_options['category_groupings'] as $name => $category_ids) { - $key = $name; - include('_category-grouping-editor.inc'); - } - ?> +
+
+ comicpress->comicpress_options['category_groupings'] as $name => $category_ids) { + $key = $name; + include('_category-grouping-editor.inc'); + } + ?> +
+ [+] Add a new category group +
+
- [+] Add a new category group - -
- + + + +

+
+ + + + + + + +
+ + + description) ?> +
+ +

+ +

+ +
+ +
- - - -

-
- - - - - - - -
- - - description) ?> -
- -

- -

- -
- -
diff --git a/css/cp-admin.css b/css/cp-admin.css index b164dd0..06ab42e 100644 --- a/css/cp-admin.css +++ b/css/cp-admin.css @@ -235,7 +235,14 @@ tr.highlighted td { /* Options */ .comicpress-tab-holder { - padding: 2px 0 + padding: 3px 0; + overflow: hidden +} + +.comicpress-tab-holder li { + float: left; + display: inline; + margin: 0 } .comicpress-tab-holder a { @@ -247,19 +254,14 @@ tr.highlighted td { border-width: 1px 0 0 1px; } -.comicpress-tab-holder a.last { +.comicpress-tab-holder .last a { border-right-width: 1px; } -.comicpress-tab-holder a.active { +.ui-tabs-selected a { background-color: white } -.comicpress-admin form { - border: solid black 1px; - padding: 0 10px 10px; -} - .category-group-holder ul ul { margin-left: 20px } @@ -277,3 +279,12 @@ tr.highlighted td { .category-group-holder .selected { background-color: #99ccbb } + +.comicpress-admin-section { + border: solid black 1px; + padding: 10px +} + +.comicpress-admin-section h3 { + margin-top: 0 +} diff --git a/js/Storyline.js b/js/Storyline.js index 5fb4563..528b6f0 100644 --- a/js/Storyline.js +++ b/js/Storyline.js @@ -2,147 +2,118 @@ var Storyline = {}; var ComicImageTypes = {}; var CategoryGroupings = {}; -(function() { +(function($) { + $.fn.setupAjax = function(action, nonce, target, onLoad) { + $(this).click(function() { + $.post( + ComicPressAdmin.ajax_uri, + { + 'cp[_nonce]': ComicPressAdmin.nonce, + 'cp[action]': action, + 'cp[_action_nonce]': nonce + }, + function(data) { + var type = $(data).hide(); + $(target).append(type); + type.slideDown(250); + if (onLoad) { onLoad(); } + } + ); + + return false; + }); + + return this; + }; + + $.fn.setupRemover = function(message, parentSearch) { + $(this).unbind('click') + .click(function() { + if (confirm(message)) { + $(this).parents(parentSearch).slideUp(250, function() { $(this).remove(); }); + } + return false; + }); + + return this; + }; + 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].replace(/\-/g,'/')); } + $('.cp-category-info').each(function() { + order.push( + $(this) + .attr('id') + .replace('category_', '') + .replace(/\-/g,'/') + ); }); - $$('input[name*=storyline_order]').pop().value = order.join(','); + $('input[name*=storyline_order]').val(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; - }); - - 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 - }); - }); - }); + $('.cp-children').sortable({ + axis: 'y', + stop: Storyline.get_order + }).disableSelection(); Storyline.get_order(); }; - ComicImageTypes.setup_checkboxes = function() { - var checkboxes = $$('input[name*=default][name*=image_types]'); - checkboxes.each(function(c) { - c.stopObserving('change'); - c.observe('change', function(e) { - checkboxes.each(function(ch) { - if (e.target != ch) { ch.checked = false; } - }); - }); - }); + ComicImageTypes.setup_editors = function() { + $('.delete-image-type').setupRemover( + 'Are you sure? Your templates may break after deleting this image type.', + '.image-type-holder' + ); }; 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); - } - }); - } - }); - } - }); + ComicImageTypes.setup_editors(); - ComicImageTypes.setup_checkboxes(); - - $('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[action]': 'get-new-image-type-editor', - 'cp[_action_nonce]': ComicPressAdmin.image_type_editor_nonce - }, - insertion: 'bottom', - onComplete: function() { - ComicImageTypes.setup_checkboxes(); - } - }); - }); + $('#add-new-image-type').setupAjax( + 'get-new-image-type-editor', + ComicPressAdmin.image_type_editor_nonce, + '#image-type-container', + ComicImageTypes.setup_editors + ); }; CategoryGroupings.highlight_child_levels = function(e) { - (function($) { - $('.category-group-holder input[type=checkbox]').attr('disabled', false); + $('.category-group-holder input[type=checkbox]').attr('disabled', false); - $('.category-group-holder li') - .removeClass('selected') - .each(function() { - if ($(this).find('input[type=checkbox]:first').is('*:checked')) { - $(this).addClass('selected').find('input[type=checkbox]').not("*:first").attr('disabled', true); - } - }); + $('.category-group-holder li') + .removeClass('selected') + .each(function() { + if ($(this).find('input[type=checkbox]:first').is('*:checked')) { + $(this).addClass('selected').find('input[type=checkbox]').not("*:first").attr('disabled', true); + } + }); - $('.category-group-holder').each(function() { - $(this).find('.empty-group-warning')[($(this).find('input:checked').length == 0) ? 'show' : 'hide'](250); - }); - }(jQuery)) + $('.category-group-holder').each(function() { + $(this).find('.empty-group-warning')[($(this).find('input:checked').length == 0) ? 'show' : 'hide'](250); + }); } CategoryGroupings.setup_editors = function() { - (function($) { - $('.category-group-holder input[type=checkbox], .category-group-holder label') - .unbind('click') - .click(CategoryGroupings.highlight_child_levels); + $('.category-group-holder input[type=checkbox], .category-group-holder label') + .unbind('click') + .click(CategoryGroupings.highlight_child_levels); - $('.delete-category-group-holder') - .unbind('click') - .click(function() { - if (confirm('Are you sure?')) { - $(this).parents('.category-group-holder').remove(); - } - }); - }(jQuery)) + $('.delete-category-group-holder').setupRemover( + 'Are you sure?', + '.category-group-holder' + ); } CategoryGroupings.setup = function() { CategoryGroupings.setup_editors(); CategoryGroupings.highlight_child_levels(); - (function($) { - $('#add-new-category-group').click(function() { - $.post( - ComicPressAdmin.ajax_uri, - { - 'cp[_nonce]': ComicPressAdmin.nonce, - 'cp[action]': 'get-new-category-group-editor', - 'cp[_action_nonce]': ComicPressAdmin.category_group_editor_nonce - }, - function(data) { - $('#category-groups-holder').append(data); - CategoryGroupings.setup_editors(); - } - ); - - return false; - }); - }(jQuery)); + $('#add-new-category-group').setupAjax( + 'get-new-category-group-editor', + ComicPressAdmin.category_group_editor_nonce, + '#category-groups-holder', + CategoryGroupings.setup_editors + ); } -}()) +}(jQuery)) diff --git a/test/ComicPressAdminTest.php b/test/ComicPressAdminTest.php index a953164..dc8b618 100644 --- a/test/ComicPressAdminTest.php +++ b/test/ComicPressAdminTest.php @@ -52,9 +52,10 @@ class ComicPressAdminTest extends PHPUnit_Framework_TestCase { ), array( 'image_types' => array( + '_default' => 'archive', 'comic' => array('dimensions' => array('width' => '500', 'height' => '50')), - 'archive' => array('default' => 'yes', 'dimensions' => array('width' => '100', 'height' => '100')), - ) + 'archive' => array('dimensions' => array('width' => '100', 'height' => '100')), + ) ), array( 'image_types' => array( diff --git a/test/selenium/TestCategoryGroupings.html b/test/selenium/TestCategoryGroupings.html index ffb2ad7..fc5d3c8 100644 --- a/test/selenium/TestCategoryGroupings.html +++ b/test/selenium/TestCategoryGroupings.html @@ -71,6 +71,11 @@ Are you sure? + + waitForElementNotPresent + //div[@id="category-groups-holder"]/div[${current_count}] + + storeXpathCount //div[@id="category-groups-holder"]/div diff --git a/test/selenium/TestComicImageTypes.html b/test/selenium/TestComicImageTypes.html new file mode 100644 index 0000000..852b7e1 --- /dev/null +++ b/test/selenium/TestComicImageTypes.html @@ -0,0 +1,107 @@ + + + + + + +TestComicImageTypes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestComicImageTypes
open/wp-admin
clickAndWaitlink=ComicPress
clickcomicpress-tab-Comic_Image_Types
assertVisiblecomicpress-Comic_Image_Types
storeXpathCount//div[@id="image-type-container"]/divcurrent_count
clickadd-new-image-type
storeEvalstoredVars['current_count']++
waitForElementPresent//div[@id="image-type-container"]/div[${current_count}]
storeXpathCount//div[@id="image-type-container"]/divnew_count
assertEval${current_count}${new_count}
assertValue//div[@id="image-type-container"]/div[${new_count}]//input[contains(@name, "[name]")]New Type
click//div[@id="image-type-container"]/div[${new_count}]//a[@class="delete-image-type"]
assertConfirmationAre you sure?*
waitForElementNotPresent//div[@id="image-type-container"]/div[${current_count}]
storeXpathCount//div[@id="image-type-container"]/divnew_count
assertEval${current_count} - 1${new_count}
clickAndWait//div[@id='comicpress-image-types-holder']/input
assertTextPresentComicPress configuration updated.
+ + diff --git a/test/selenium/TestSuiteComicPressAdmin.html b/test/selenium/TestSuiteComicPressAdmin.html new file mode 100644 index 0000000..c39f8a4 --- /dev/null +++ b/test/selenium/TestSuiteComicPressAdmin.html @@ -0,0 +1,16 @@ + + + + + + Test Suite + + + + + + + +
Test Suite
TestCategoryGroupings
TestComicImageTypes
Untitled
+ +