From d2e0d6bdf13325c2569dd2c9031149d8904a6c0f Mon Sep 17 00:00:00 2001 From: gucheen Date: Sun, 19 Jan 2014 18:06:15 +0800 Subject: [PATCH] change the method of control button to make the plugin work with several object --- .gitignore | 1 + index.html | 28 ++++++++++++++++++++++------ jquery.popmenu.min.js | 2 +- src/jquery.popmenu.js | 2 +- 4 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..38f8e88 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dev diff --git a/index.html b/index.html index ff46580..546c8fc 100644 --- a/index.html +++ b/index.html @@ -22,8 +22,7 @@ color: #3498db; } footer{ - position: absolute; - bottom: 100px; + margin-top: 150px; } @@ -31,10 +30,10 @@ Fork me on GitHub

jQuery pop menu

- click the button below to have a try. + click these buttons below to have a try.
-
+
  • Home
  • Cloud
  • @@ -47,9 +46,25 @@

    jQuery pop menu

  • Exit
-
-$('#demo_box').popmenu();
+        
+
+
    +
  • Home
  • +
  • Cloud
  • +
  • settings
  • +
  • E-mail
  • +
  • Clock
  • +
  • Files
  • +
  • Favourites
  • +
  • Mobile
  • +
  • Exit
  • +
+
+

How to use:

+
+  $('#demo_box').popmenu();
         
+

Find more information on github.

Code By Guc.
@@ -59,6 +74,7 @@

jQuery pop menu

diff --git a/jquery.popmenu.min.js b/jquery.popmenu.min.js index db79e2f..7d320a5 100644 --- a/jquery.popmenu.min.js +++ b/jquery.popmenu.min.js @@ -1 +1 @@ -!function(o){o.fn.popmenu=function(r){function t(){i.css({display:e,position:"absolute","margin-top":-n.top,"margin-left":-n.left,background:n.background,width:n.width,"float":"left",padding:"0","border-radius":n.borderRadius}),s.css({display:"block",color:"#fff","float":"left",width:n.iconSize,height:n.iconSize,"text-align":"center","border-radius":n.borderRadius}),u.css({"text-decoration":"none",color:"#fff"}),a.hover(function(){a.css("cursor","pointer")},function(){a.css("cursor","default")}),a.click(function(r){r.preventDefault(),i.show("fast"),o(document).mouseup(function(o){var r=i;r.is(o.target)||0!==r.has(o.target).length||r.hide(),r.hide()})}),s.hover(function(){o(this).css({background:n.focusColor,cursor:"pointer"})},function(){o(this).css({background:n.background,cursor:"default"})})}var n=o.extend({controller:!0,width:"300px",background:"#34495e",focusColor:"#1abc9c",borderRadius:"10px",top:"50",left:"0",iconSize:"100px"},r);if(n.controller===!0)var e="none";else e="block";var c=o(this),i=c.children("ul"),s=i.children("li"),u=s.children("a"),a=o("#pop_ctrl");return t()}}(jQuery); \ No newline at end of file +!function(a){a.fn.popmenu=function(b){function j(){f.css({display:d,position:"absolute","margin-top":-c.top,"margin-left":-c.left,background:c.background,width:c.width,"float":"left",padding:"0","border-radius":c.borderRadius}),g.css({display:"block",color:"#fff","float":"left",width:c.iconSize,height:c.iconSize,"text-align":"center","border-radius":c.borderRadius}),h.css({"text-decoration":"none",color:"#fff"}),i.hover(function(){i.css("cursor","pointer")},function(){i.css("cursor","default")}),i.click(function(b){b.preventDefault(),f.show("fast"),a(document).mouseup(function(a){var b=f;b.is(a.target)||0!==b.has(a.target).length||b.hide(),b.hide()})}),g.hover(function(){a(this).css({background:c.focusColor,cursor:"pointer"})},function(){a(this).css({background:c.background,cursor:"default"})})}var c=a.extend({controller:!0,width:"300px",background:"#34495e",focusColor:"#1abc9c",borderRadius:"10px",top:"50",left:"0",iconSize:"100px"},b);if(c.controller===!0)var d="none";else d="block";var e=a(this),f=e.children("ul"),g=f.children("li"),h=g.children("a"),i=e.children(".pop_ctrl");return j()}}(jQuery); \ No newline at end of file diff --git a/src/jquery.popmenu.js b/src/jquery.popmenu.js index b80bcd3..e34a84a 100644 --- a/src/jquery.popmenu.js +++ b/src/jquery.popmenu.js @@ -28,7 +28,7 @@ Based on jQuery 2.0.3 var tar_body = tar.children('ul'); var tar_list = tar_body.children('li'); var tar_a = tar_list.children('a'); - var tar_ctrl = $('#pop_ctrl'); + var tar_ctrl = tar.children('.pop_ctrl'); function setIt() { tar_body.css({