From aa1f0d86bd30cfd62b0838423a25c883077d068e Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 5 Feb 2010 19:49:09 -0500 Subject: [PATCH] start swapping out prototype for jquery --- comicpress-core.php | 8 ++-- js/Storyline.js | 72 +++++++++++++++---------------- test/ComicPressTagBuilderTest.php | 1 + 3 files changed, 38 insertions(+), 43 deletions(-) diff --git a/comicpress-core.php b/comicpress-core.php index 8ad96b6..82c3214 100644 --- a/comicpress-core.php +++ b/comicpress-core.php @@ -44,9 +44,7 @@ function __comicpress_init() { $comicpress = ComicPress::get_instance(); $comicpress->init(); - if (is_admin()) { - $comicpress_admin = new ComicPressAdmin(); - $comicpress_admin->init(); - $comicpress_admin->handle_update(); - } + $comicpress_admin = new ComicPressAdmin(); + $comicpress_admin->init(); + $comicpress_admin->handle_update(); } diff --git a/js/Storyline.js b/js/Storyline.js index 91d16c2..3bc3252 100644 --- a/js/Storyline.js +++ b/js/Storyline.js @@ -89,56 +89,52 @@ var CategoryGroupings = {}; }; CategoryGroupings.highlight_child_levels = function(e) { - $$('.category-group-holder input[type=checkbox]').each(function(cb) { - cb.disabled = false; - }); + (function($) { + $('.category-group-holder input[type=checkbox]').attr('disabled', false); - $$('.category-group-holder li').each(function(li) { - var all_cb = li.select('input[type=checkbox]'); - var cb = all_cb.shift(); - li.removeClassName('selected'); - if (cb && cb.checked) { - all_cb.each(function(ncb) { - ncb.disabled = true; - }); - li.addClassName('selected'); - } - }); + $('.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(cgh) { - var all_off = true; - cgh.select('input[type=checkbox]').each(function(c) { - if (c.checked) { all_off = false; } + $('.category-group-holder').each(function() { + $(this).find('.empty-group-warning')[($(this).find('input:checked').length == 0) ? 'show' : 'hide'](250); }); - cgh.select('.empty-group-warning').pop()[all_off ? 'show' : 'hide'](); - }); + }(jQuery)) } CategoryGroupings.setup_editors = function() { - $$('.category-group-holder input[type=checkbox], .category-group-holder label').each(function(cb) { - cb.stopObserving('click'); - cb.observe('click', CategoryGroupings.highlight_child_levels); - }); + (function($) { + $('.category-group-holder input[type=checkbox], .category-group-holder label') + .unbind('click') + .click(CategoryGroupings.highlight_child_levels); + }(jQuery)) } CategoryGroupings.setup = function() { CategoryGroupings.setup_editors(); CategoryGroupings.highlight_child_levels(); - $('add-new-category-group').observe('click', function(e) { - Event.stop(e); - new Ajax.Updater('category-groups-holder', ComicPressAdmin.ajax_uri, { - method: 'get', - parameters: { - 'cp[_nonce]': ComicPressAdmin.nonce, - 'cp[action]': 'get-new-category-group-editor', - 'cp[_action_nonce]': ComicPressAdmin.category_group_editor_nonce - }, - onComplete: function() { - CategoryGroupings.setup_editors(); - }, - insertion: 'bottom' + (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)); } }()) diff --git a/test/ComicPressTagBuilderTest.php b/test/ComicPressTagBuilderTest.php index 462a37e..e017d15 100644 --- a/test/ComicPressTagBuilderTest.php +++ b/test/ComicPressTagBuilderTest.php @@ -77,6 +77,7 @@ class ComicPressTagBuilderTest extends PHPUnit_Framework_TestCase { /** * @dataProvider providerTestBuilder */ + // TODO same_category function testStorylineBuilder($instructions, $expected_dbi_call, $expects_setup_postdata = false) { global $post, $wp_test_expectations; $post = 'current-post';