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
|
||||||
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 = {})
|
def collection_to_js(collection, options = {})
|
||||||
js = collection.collect { |object| object.to_json }
|
js = collection.collect { |object| object.to_json }
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
- with_children = !children.empty?
|
- with_children = !children.empty?
|
||||||
|
|
||||||
- if not page.index? and with_children
|
- if not page.index? and with_children
|
||||||
= image_tag 'admin/list/icons/node_closed.png', :class => 'toggler'
|
= admin_item_toggler(page)
|
||||||
|
|
||||||
%em
|
%em
|
||||||
%strong= link_to truncate(page.title, :length => 80), edit_admin_page_url(page)
|
%strong= link_to truncate(page.title, :length => 80), edit_admin_page_url(page)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
// open / close folder
|
// open / close folder
|
||||||
|
if (typeof $.fn.toggleMe != 'undefined')
|
||||||
$('#pages-list ul.folder img.toggler').toggleMe();
|
$('#pages-list ul.folder img.toggler').toggleMe();
|
||||||
|
|
||||||
// sortable folder items
|
// sortable folder items
|
||||||
|
|
|
@ -1,41 +1,33 @@
|
||||||
/**
|
/**
|
||||||
* Version 1.0
|
* Version 1.0.1
|
||||||
* Init and deploy childs on menu (admin)
|
* Init and deploy childs on menu (admin)
|
||||||
* Benjamin Athlan - Bewcultures
|
* Benjamin Athlan - Bewcultures
|
||||||
|
* Andrew Bennett - Delorum
|
||||||
*/
|
*/
|
||||||
$.fn.toggleMe = function(settings) {
|
$.fn.toggleMe = function(settings) {
|
||||||
|
|
||||||
settings = $.extend({
|
settings = $.extend({}, settings);
|
||||||
}, settings);
|
|
||||||
|
|
||||||
function toggle(element){
|
var toggle = function(event) {
|
||||||
var children = $(element).parent().find('> ul.folder');
|
var toggler = $(this);
|
||||||
|
var children = toggler.parent().find('> ul.folder');
|
||||||
|
|
||||||
children.each(function() {
|
children.each(function() {
|
||||||
if ($(this).is(':visible')) {
|
var child = $(this);
|
||||||
$(this).slideUp('fast', function() {
|
if (child.is(':visible')) {
|
||||||
element.attr('src', element.attr('src').replace('open', 'closed'));
|
child.slideUp('fast', function() {
|
||||||
$.cookie($(this).attr('id'), 'none');
|
toggler.attr('src', toggler.attr('src').replace('open', 'closed'));
|
||||||
|
$.cookie(child.attr('id'), 'none');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$(this).slideDown('fast', function() {
|
child.slideDown('fast', function() {
|
||||||
element.attr('src', element.attr('src').replace('closed', 'open'));
|
toggler.attr('src', toggler.attr('src').replace('closed', 'open'));
|
||||||
$.cookie($(this).attr('id'), 'block');
|
$.cookie(child.attr('id'), 'block');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.each(function(){
|
return $(this).bind("click", toggle);
|
||||||
toggle($(this));
|
|
||||||
|
|
||||||
$(this).bind("click", function(){
|
|
||||||
// console.log(this);
|
|
||||||
toggle($(this));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue