1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-07-31 02:10:37 +02:00

Pages Plugin: general js refactoring

This commit is contained in:
Awilum
2012-11-17 20:49:02 +02:00
parent 02f9f7f01a
commit 580ff98951
3 changed files with 45 additions and 32 deletions

View File

@@ -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();
});

View File

@@ -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 ('<script>
function pageExpand(slug, expand, token) {
$.ajax({
type:"post",
data:"slug="+slug+"&expand="+expand+"&token="+token,
url: "'.Option::get('siteurl').'admin/index.php?id=pages"
});
}
$(document).ready(function() {
$(".parent").click(function() {
if ($(this).html() == "-") {
$(\'[rel="children_\' + $(this).attr(\'rel\')+\'"]\').hide();
$(this).html("+");
pageExpand($(this).attr("rel"), "1", $(this).attr("token"));
} else {
$(\'[rel="children_\' + $(this).attr(\'rel\')+\'"]\').show();
$(this).html("-");
pageExpand($(this).attr("rel"), "0", $(this).attr("token"));
}
});
});
</script>');
}
/**
* Pages admin function

View File

@@ -98,5 +98,9 @@
</tbody>
</table>
<form>
<input type="hidden" name="url" value="<?php echo Option::get('siteurl'); ?>admin/index.php?id=pages">
</form>
</div>
</div>