Created
October 15, 2010 03:11
-
-
Save qoelet/627542 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Menu = Backbone.Model.extend({ | |
dimOld: function() { | |
var id = this.previous('current'); | |
$('#'+id).removeClass('selected'); | |
}, | |
lightNew: function(current) { | |
$('#'+current).addClass('selected'); | |
} | |
}); | |
// initialize instances + properties | |
var menu = new Menu; | |
menu.set({current: ""}); | |
// Bind event when user clicks on a menu item | |
menu.bind("change:current", function(obj) { | |
menu.dimOld(); | |
menu.lightNew(obj.get('current')); | |
}); | |
var menu_arr = ($('#sidebar li')); | |
$.each(menu_arr, function(i, val) { | |
(function() { | |
$(menu_arr[i]).click(function() { | |
var this_id = $(menu_arr[i]).attr("id"); | |
$('div#v_'+menu.previous('current')).fadeOut(); | |
menu.set({current: this_id}); | |
$('div#v_'+this_id).delay(900).fadeIn(); | |
}) | |
})(menu_arr[i]) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment