include potatosalad's work about the menu_toggler

This commit is contained in:
did 2011-07-05 21:03:10 +02:00
parent 59a6e03da2
commit 6ce086520f
4 changed files with 32 additions and 34 deletions

View File

@ -39,6 +39,10 @@ module Admin::BaseHelper
end
end
def admin_item_toggler(object)
image_tag("admin/list/icons/node_#{(cookies["folder-#{object._id}"] != 'none') ? 'open' : 'closed'}.png", :class => 'toggler')
end
def collection_to_js(collection, options = {})
js = collection.collect { |object| object.to_json }

View File

@ -5,7 +5,8 @@
- with_children = !children.empty?
- if not page.index? and with_children
= image_tag 'admin/list/icons/node_closed.png', :class => 'toggler'
= admin_item_toggler(page)
%em
%strong= link_to truncate(page.title, :length => 80), edit_admin_page_url(page)

View File

@ -1,6 +1,7 @@
$(document).ready(function() {
// open / close folder
if (typeof $.fn.toggleMe != 'undefined')
$('#pages-list ul.folder img.toggler').toggleMe();
// sortable folder items

View File

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