Created
March 12, 2013 21:52
-
-
Save moustafasamir/5147429 to your computer and use it in GitHub Desktop.
backbone view, Dropdown on hover
This file contains 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
class DropdownView extends BaseView | |
# el: ".header" | |
events:()=> | |
events_hash = {} | |
events_hash["mouseover #{@link_selector}"] ="showMenu" | |
events_hash["mouseleave #{@link_selector}"] ="btnLeave" | |
events_hash["mouseleave #{@menu_selector}"] ="hideMenu" | |
events_hash["mouseover #{@menu_selector}"] ="insideMenu" | |
return events_hash | |
initialize: (options)-> | |
@link_selector = options.link_selector | |
@menu_selector = options.menu_selector | |
showMenu: => | |
@$('.dropdown').hide() #hide other menus | |
@$(@menu_selector).show() | |
@insideItemMenu = true | |
hideMenu: => | |
@$(@menu_selector).hide() | |
@insideItemMenu = false | |
insideMenu: => | |
@$(@menu_selector).show() | |
@insideItemMenu = true | |
btnLeave: => | |
@insideItemMenu = false | |
window.setTimeout => | |
unless @insideItemMenu == true | |
@$(@menu_selector).hide() | |
@insideItemMenu = false | |
,500 |
This file contains 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
new DropdownView({link_selector:"#hover_btn", menu_selector:"#hover_menu", el: "#pparent_element"}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment