mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-02 19:27:52 +02:00
Pages Plugin: general js refactoring
This commit is contained in:
36
plugins/box/pages/js/pages.js
Normal file
36
plugins/box/pages/js/pages.js
Normal 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();
|
||||||
|
});
|
@@ -2,9 +2,13 @@
|
|||||||
|
|
||||||
Navigation::add(__('Pages', 'pages'), 'content', 'pages', 1);
|
Navigation::add(__('Pages', 'pages'), 'content', 'pages', 1);
|
||||||
|
|
||||||
Action::add('admin_header', 'PagesAdmin::_themeHeaders');
|
|
||||||
Action::add('admin_pre_render','PagesAdmin::_pageExpandAjax');
|
Action::add('admin_pre_render','PagesAdmin::_pageExpandAjax');
|
||||||
|
|
||||||
|
// Add Plugin Javascript
|
||||||
|
Javascript::add('plugins/box/pages/js/pages.js', 'backend');
|
||||||
|
|
||||||
|
|
||||||
class PagesAdmin extends Backend {
|
class PagesAdmin extends Backend {
|
||||||
|
|
||||||
|
|
||||||
@@ -30,37 +34,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
|
* Pages admin function
|
||||||
*/
|
*/
|
||||||
|
@@ -98,5 +98,9 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<form>
|
||||||
|
<input type="hidden" name="url" value="<?php echo Option::get('siteurl'); ?>admin/index.php?id=pages">
|
||||||
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
Reference in New Issue
Block a user