bitetti

Base Menu for Wordpress revised

Jan 11th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $=jQuery
  2.  
  3. class ApplicationMenu
  4.     constructor: (nome) ->
  5.         @menu = $ ".menu"
  6.         @menu.find("li").click @click
  7.         @menu.find("ul .children").attr("class","children menuBorder").hide().each (i,e) ->
  8.             el = $ e
  9.             el.parent().data("__menu", el)
  10.             el.remove()
  11.             $(document.body).append el
  12.         @menuIsShow = false
  13.         @active = null
  14.     click: (e) =>
  15.         el = $ e.currentTarget
  16.         #hasChilds = el.find("ul").length>0 ? true : false
  17.         child = el.data("__menu")
  18.         if child != undefined
  19.             @menuIsShow = true
  20.             @active = child
  21.             #@active = $(el.find('ul')[0]).fadeIn("slow")
  22.             pos = el.offset()
  23.             @active.css({"left":pos.left-12,"top":pos.top+8,"bottom":0}).fadeIn("fast")
  24.             $(document.body).bind "mouseup", @hide
  25.         return false
  26.     hide: (e) =>
  27.         if @menuIsShow
  28.             @active.fadeOut("fast")
  29.             $(document.body).unbind "mouseup", @hide
  30.  
  31.  
  32. $ ->
  33.     new ApplicationMenu()
  34.  
  35.  
  36. ###
  37. <style type="text/css">
  38.     li {
  39.         float: left;
  40.         display: inline;
  41.     }
  42.  
  43. .menuBorder {
  44.     position: absolute;
  45.     margin-right: 12px;
  46.     margin-left: 12px;
  47.     -webkit-border-radius: 12px 12px 0px 0px;
  48.     border-radius: 12px 12px 0px 0px;
  49.     border: 1px solid #fff;
  50.     /*outline: 2px solid #ffffff;*/
  51.     /*outline-offset: 10px; Delete if you don't want an offset*/
  52.     background: -moz-linear-gradient(top,  rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.8) 57%, rgba(0,0,0,0) 100%); /* FF3.6+ */
  53.     background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.8)), color-stop(57%,rgba(0,0,0,0.8)), color-stop(100%,rgba(0,0,0,0))); /* Chrome,Safari4+ */
  54.     background: -webkit-linear-gradient(top,  rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.8) 57%,rgba(0,0,0,0) 100%); /* Chrome10+,Safari5.1+ */
  55.     background: -o-linear-gradient(top,  rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.8) 57%,rgba(0,0,0,0) 100%); /* Opera 11.10+ */
  56.     background: -ms-linear-gradient(top,  rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.8) 57%,rgba(0,0,0,0) 100%); /* IE10+ */
  57.     background: linear-gradient(to bottom,  rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.8) 57%,rgba(0,0,0,0) 100%); /* W3C */
  58.     filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cc000000', endColorstr='#00000000',GradientType=0 ); /* IE6-9 */
  59.  
  60. }
  61.  
  62. </style>
  63. ###
Advertisement
Add Comment
Please, Sign In to add comment