From 580ff989512fce387d59ef70201cc912f3841625 Mon Sep 17 00:00:00 2001 From: Awilum Date: Sat, 17 Nov 2012 20:49:02 +0200 Subject: [PATCH] Pages Plugin: general js refactoring --- plugins/box/pages/js/pages.js | 36 ++++++++++++++++++ plugins/box/pages/pages.admin.php | 37 +++---------------- .../box/pages/views/backend/index.view.php | 4 ++ 3 files changed, 45 insertions(+), 32 deletions(-) create mode 100644 plugins/box/pages/js/pages.js diff --git a/plugins/box/pages/js/pages.js b/plugins/box/pages/js/pages.js new file mode 100644 index 0000000..52aa4e4 --- /dev/null +++ b/plugins/box/pages/js/pages.js @@ -0,0 +1,36 @@ +if (typeof $.monstra == 'undefined') $.monstra = {}; + +$.monstra.pages = { + + init: function() { + this.pagesExpandProcess(); + }, + + pageExpand: function(slug, expand, token) { + $.ajax({ + type:"post", + data:"slug="+slug+"&expand="+expand+"&token="+token, + url: $('form input[name="siteurl"]').val() + }); + }, + + pagesExpandProcess: function() { + $(".parent").click(function() { + if ($(this).html() == "-") { + $('[rel="children_' + $(this).attr('rel')+'"]').hide(); + $(this).html("+"); + $.monstra.pages.pageExpand($(this).attr("rel"), "1", $(this).attr("token")); + } else { + $('[rel="children_' + $(this).attr('rel')+'"]').show(); + $(this).html("-"); + $.monstra.pages.pageExpand($(this).attr("rel"), "0", $(this).attr("token")); + } + }); + } + +}; + + +$(document).ready(function(){ + $.monstra.pages.init(); +}); \ No newline at end of file diff --git a/plugins/box/pages/pages.admin.php b/plugins/box/pages/pages.admin.php index b457d62..83ffc1d 100755 --- a/plugins/box/pages/pages.admin.php +++ b/plugins/box/pages/pages.admin.php @@ -2,9 +2,13 @@ Navigation::add(__('Pages', 'pages'), 'content', 'pages', 1); - Action::add('admin_header', 'PagesAdmin::_themeHeaders'); + Action::add('admin_pre_render','PagesAdmin::_pageExpandAjax'); + // Add Plugin Javascript + Javascript::add('plugins/box/pages/js/pages.js', 'backend'); + + class PagesAdmin extends Backend { @@ -29,37 +33,6 @@ } } - - /** - * _themeHeaders - */ - public static function _themeHeaders() { - echo (''); - } - /** * Pages admin function diff --git a/plugins/box/pages/views/backend/index.view.php b/plugins/box/pages/views/backend/index.view.php index d0ab2f9..756b912 100755 --- a/plugins/box/pages/views/backend/index.view.php +++ b/plugins/box/pages/views/backend/index.view.php @@ -98,5 +98,9 @@ +
+ +
+ \ No newline at end of file