Merge pull request #81 from bewculture/master

Fixed JS bugs
This commit is contained in:
Didier Lafforgue 2011-07-05 11:37:48 -07:00
commit 59a6e03da2
4 changed files with 44 additions and 15 deletions

View File

@ -53,3 +53,4 @@ h2. Contact
Feel free to contact me at didier at nocoffee dot fr.
Copyright (c) 2011 NoCoffee, released under the MIT license
...

View File

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

View File

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