include potatosalad's work about the menu_toggler
This commit is contained in:
parent
59a6e03da2
commit
6ce086520f
@ -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 }
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
// open / close folder
|
||||
$('#pages-list ul.folder img.toggler').toggleMe();
|
||||
if (typeof $.fn.toggleMe != 'undefined')
|
||||
$('#pages-list ul.folder img.toggler').toggleMe();
|
||||
|
||||
// sortable folder items
|
||||
$('#pages-list ul.folder').sortable({
|
||||
|
@ -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);
|
||||
|
||||
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));
|
||||
settings = $.extend({}, settings);
|
||||
|
||||
var toggle = function(event) {
|
||||
var toggler = $(this);
|
||||
var children = toggler.parent().find('> ul.folder');
|
||||
|
||||
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 {
|
||||
child.slideDown('fast', function() {
|
||||
toggler.attr('src', toggler.attr('src').replace('closed', 'open'));
|
||||
$.cookie(child.attr('id'), 'block');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
return $(this).bind("click", toggle);
|
||||
|
||||
};
|
Loading…
Reference in New Issue
Block a user