Fixed open/close folder arrows by plugin

This commit is contained in:
Benjamin Athlan 2011-05-18 18:27:24 +02:00
parent 2e76ebd521
commit a224aff063
3 changed files with 43 additions and 18 deletions

View File

@ -56,6 +56,7 @@ javascripts:
- public/javascripts/admin/account.js - public/javascripts/admin/account.js
pages: pages:
- public/javascripts/admin/pages.js - public/javascripts/admin/pages.js
- public/javascripts/admin/menu_toggler.js
edit_page: edit_page:
- public/javascripts/admin/plugins/tiny_mce/tinymce.js - public/javascripts/admin/plugins/tiny_mce/tinymce.js
- public/javascripts/admin/editable_elements.js - public/javascripts/admin/editable_elements.js

View File

@ -1,24 +1,7 @@
$(document).ready(function() { $(document).ready(function() {
// open / close folder // open / close folder
$('#pages-list ul.folder img.toggler').click(function(e) { $('#pages-list ul.folder img.toggler').toggleMe();
var toggler = $(this);
var children = toggler.parent().find('> ul.folder');
children.each(function(){
if ($(this).is(':visible')) {
$(this).slideUp('fast', function() {
toggler.attr('src', toggler.attr('src').replace('open', 'closed'));
$.cookie($(this).attr('id'), 'none');
});
} else {
$(this).slideDown('fast', function() {
toggler.attr('src', toggler.attr('src').replace('closed', 'open'));
$.cookie($(this).attr('id'), 'block');
});
}
});
});
// sortable folder items // sortable folder items
$('#pages-list ul.folder').sortable({ $('#pages-list ul.folder').sortable({

View File

@ -0,0 +1,41 @@
/**
* Version 1.0
* Init and deploy childs on menu (admin)
* Benjamin Athlan - Bewcultures
*/
$.fn.toggleMe = function(settings) {
settings = $.extend({
}, settings);
function toggle(element){
var children = $(element).parent().find('> ul.folder');
children.each(function(){
if ($(this).is(':visible')) {
$(this).slideUp('fast', function() {
element.attr('src', element.attr('src').replace('open', 'closed'));
$.cookie($(this).attr('id'), 'none');
});
} else {
$(this).slideDown('fast', function() {
element.attr('src', element.attr('src').replace('closed', 'open'));
$.cookie($(this).attr('id'), 'block');
});
}
});
};
return this.each(function(){
toggle($(this));
$(this).bind("click", function(){
// console.log(this);
toggle($(this));
});
});
};