<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: MooTools ContextMenu&#160;Plugin</title> <atom:link href="http://davidwalsh.name/mootools-context-menu/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/mootools-context-menu</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Thu, 09 Sep 2010 10:38:51 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>By: Niklas Lehto</title><link>http://davidwalsh.name/mootools-context-menu/comment-page-1#comment-18578</link> <dc:creator>Niklas Lehto</dc:creator> <pubDate>Mon, 05 Jul 2010 06:54:39 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-18578</guid> <description>One further revision. I found myself in need of adding and removing trigger items, so I added two methods providing this functionality, and broke another method up in two. Here are the changes (with my previous revisions included)://get things started
startListener: function(){
//all elemnts
this.attachToTargets(this.targets);//menu items
this.menu.getElements(&#039;a&#039;).each(function(item){
item.addEvent(&#039;click&#039;,function(e){
if(!item.hasClass(&#039;disabled&#039;)){
this.execute(item.get(&#039;href&#039;).split(&#039;#&#039;)[1],document.id(this.options.element));
this.fireEvent(&#039;click&#039;,[item,e]);
}
}.bind(this));
},this);//hide on body click
document.id(document.body).addEvents({
&#039;click&#039;: function(){
this.hide();
}.bind(this),
&#039;contextmenu&#039;: function(){
this.hide();
}.bind(this)
});
},// add trigger event to all targets
attachToTargets: function(targets){
targets.each(function(el){
//show the menu
el.addEvent(this.options.trigger,function(e){
//enabled?
if(!this.options.disabled){
//prevent default, if told to
if(this.options.stopEvent) { e.stop(); }
//record this as the trigger
this.options.element = document.id(el);
//calculate height of the menu
menuSize = this.menu.measure(function(){
return this.getSize();
});
//decide where to position the menu
posY =	((e.page.y + this.options.offsets.y + menuSize.y) &lt; window.getSize().y)
? e.page.y + this.options.offsets.y
: e.page.y - this.options.offsets.y - menuSize.y;
posX =	((e.page.x + this.options.offsets.x + menuSize.x) &lt; window.getSize().x)
? e.page.x + this.options.offsets.x
: e.page.x - this.options.offsets.x - menuSize.x;
//position the menu
this.menu.setStyles({
top: posY,
left: posX,
position: &#039;absolute&#039;,
&#039;z-index&#039;: &#039;2000&#039;
});
//show the menu
this.show();
}
}.bind(this));
},this);
},//add item(s)
addItems: function(items){
this.attachToTargets($$(items));
},//remove item(s)
removeItems: function(items){
$$(items).removeEvents(this.options.trigger);
},</description> <content:encoded><![CDATA[<p>One further revision. I found myself in need of adding and removing trigger items, so I added two methods providing this functionality, and broke another method up in two. Here are the changes (with my previous revisions included):</p><p> //get things started<br
/> startListener: function(){<br
/> //all elemnts<br
/> this.attachToTargets(this.targets);</p><p> //menu items<br
/> this.menu.getElements(&#8216;a&#8217;).each(function(item){<br
/> item.addEvent(&#8216;click&#8217;,function(e){<br
/> if(!item.hasClass(&#8216;disabled&#8217;)){<br
/> this.execute(item.get(&#8216;href&#8217;).split(&#8216;#&#8217;)[1],document.id(this.options.element));<br
/> this.fireEvent(&#8216;click&#8217;,[item,e]);<br
/> }<br
/> }.bind(this));<br
/> },this);</p><p> //hide on body click<br
/> document.id(document.body).addEvents({<br
/> &#8216;click&#8217;: function(){<br
/> this.hide();<br
/> }.bind(this),<br
/> &#8216;contextmenu&#8217;: function(){<br
/> this.hide();<br
/> }.bind(this)<br
/> });<br
/> },</p><p> // add trigger event to all targets<br
/> attachToTargets: function(targets){<br
/> targets.each(function(el){<br
/> //show the menu<br
/> el.addEvent(this.options.trigger,function(e){<br
/> //enabled?<br
/> if(!this.options.disabled){<br
/> //prevent default, if told to<br
/> if(this.options.stopEvent) { e.stop(); }<br
/> //record this as the trigger<br
/> this.options.element = document.id(el);<br
/> //calculate height of the menu<br
/> menuSize = this.menu.measure(function(){<br
/> return this.getSize();<br
/> });<br
/> //decide where to position the menu<br
/> posY =	((e.page.y + this.options.offsets.y + menuSize.y) &lt; window.getSize().y)<br
/> ? e.page.y + this.options.offsets.y<br
/> : e.page.y &#8211; this.options.offsets.y &#8211; menuSize.y;<br
/> posX =	((e.page.x + this.options.offsets.x + menuSize.x) &lt; window.getSize().x)<br
/> ? e.page.x + this.options.offsets.x<br
/> : e.page.x &#8211; this.options.offsets.x &#8211; menuSize.x;<br
/> //position the menu<br
/> this.menu.setStyles({<br
/> top: posY,<br
/> left: posX,<br
/> position: &#039;absolute&#039;,<br
/> &#039;z-index&#039;: &#039;2000&#039;<br
/> });<br
/> //show the menu<br
/> this.show();<br
/> }<br
/> }.bind(this));<br
/> },this);<br
/> },</p><p> //add item(s)<br
/> addItems: function(items){<br
/> this.attachToTargets($$(items));<br
/> },</p><p> //remove item(s)<br
/> removeItems: function(items){<br
/> $$(items).removeEvents(this.options.trigger);<br
/> },</p> ]]></content:encoded> </item> <item><title>By: Niklas Lehto</title><link>http://davidwalsh.name/mootools-context-menu/comment-page-1#comment-18560</link> <dc:creator>Niklas Lehto</dc:creator> <pubDate>Sun, 04 Jul 2010 00:22:20 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-18560</guid> <description>Btw, it&#039;s tested to work in recent PC versions of Firefox, Explorer, Chrome, Opera and Safari.</description> <content:encoded><![CDATA[<p>Btw, it&#8217;s tested to work in recent PC versions of Firefox, Explorer, Chrome, Opera and Safari.</p> ]]></content:encoded> </item> <item><title>By: Niklas Lehto</title><link>http://davidwalsh.name/mootools-context-menu/comment-page-1#comment-18559</link> <dc:creator>Niklas Lehto</dc:creator> <pubDate>Sun, 04 Jul 2010 00:16:10 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-18559</guid> <description>Brilliant! Have implemented this in a project I&#039;m working on. I&#039;ve added some functionality to decide whether to position the menu above or below and to the left or the right of the cursor, depending on the size of the menu and the viewport. Hope someone finds it useful.//calculate height of the menu
menuSize = this.menu.measure(function(){
return this.getSize();
});
//decide where to position the menu
posY =	((e.page.y + this.options.offsets.y + menuSize.y) &lt; window.getSize().y)
? e.page.y + this.options.offsets.y
: e.page.y - this.options.offsets.y - menuSize.y;
posX =	((e.page.x + this.options.offsets.x + menuSize.x) &lt; window.getSize().x)
? e.page.x + this.options.offsets.x
: e.page.x - this.options.offsets.x - menuSize.x;
//position the menu
this.menu.setStyles({
top: posY,
left: posX,
position: &#039;absolute&#039;,
&#039;z-index&#039;: &#039;2000&#039;
});</description> <content:encoded><![CDATA[<p>Brilliant! Have implemented this in a project I&#8217;m working on. I&#8217;ve added some functionality to decide whether to position the menu above or below and to the left or the right of the cursor, depending on the size of the menu and the viewport. Hope someone finds it useful.</p><p>//calculate height of the menu<br
/> menuSize = this.menu.measure(function(){<br
/> return this.getSize();<br
/> });<br
/> //decide where to position the menu<br
/> posY =	((e.page.y + this.options.offsets.y + menuSize.y) &lt; window.getSize().y)<br
/> ? e.page.y + this.options.offsets.y<br
/> : e.page.y &#8211; this.options.offsets.y &#8211; menuSize.y;<br
/> posX =	((e.page.x + this.options.offsets.x + menuSize.x) &lt; window.getSize().x)<br
/> ? e.page.x + this.options.offsets.x<br
/> : e.page.x &#8211; this.options.offsets.x &#8211; menuSize.x;<br
/> //position the menu<br
/> this.menu.setStyles({<br
/> top: posY,<br
/> left: posX,<br
/> position: &#039;absolute&#039;,<br
/> &#039;z-index&#039;: &#039;2000&#039;<br
/> });</p> ]]></content:encoded> </item> <item><title>By: 123doing</title><link>http://davidwalsh.name/mootools-context-menu/comment-page-1#comment-18345</link> <dc:creator>123doing</dc:creator> <pubDate>Tue, 22 Jun 2010 02:01:02 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-18345</guid> <description>It&#039;s very good.
I like this.
Thanks for share.
And I wrote something to introduce this project for my readers.
You can find the post about this in my website.
If something is wrong,pls figure it out.thanks.</description> <content:encoded><![CDATA[<p>It&#8217;s very good.<br
/> I like this.<br
/> Thanks for share.<br
/> And I wrote something to introduce this project for my readers.<br
/> You can find the post about this in my website.<br
/> If something is wrong,pls figure it out.thanks.</p> ]]></content:encoded> </item> <item><title>By: David Hinckle</title><link>http://davidwalsh.name/mootools-context-menu/comment-page-1#comment-18123</link> <dc:creator>David Hinckle</dc:creator> <pubDate>Thu, 10 Jun 2010 17:46:46 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-18123</guid> <description>Hi David,I&#039;m attempting to use your contextMenu class yet again but have a question. If I rightclick on a tr (targets: &#039;tbody tr&#039;), how do I get the contextmenu to close when I mouseout of the same row? THANKS AGAIN!</description> <content:encoded><![CDATA[<p>Hi David,</p><p>I&#8217;m attempting to use your contextMenu class yet again but have a question. If I rightclick on a tr (targets: &#8216;tbody tr&#8217;), how do I get the contextmenu to close when I mouseout of the same row? THANKS AGAIN!</p> ]]></content:encoded> </item> <item><title>By: Nestor</title><link>http://davidwalsh.name/mootools-context-menu/comment-page-1#comment-17221</link> <dc:creator>Nestor</dc:creator> <pubDate>Thu, 22 Apr 2010 10:17:27 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-17221</guid> <description>Oh, dear, my HTML code got parsed...
What I wanted to say was:imagine you have two spans: (I replaced &quot;&quot; with &quot;@&quot;)@span class=&quot;mif-tree-name&quot;@ Click me @/span@
@span class=&quot;some-class&quot;@ Click me @/span@Then if you do as described above, only the first span will have the JS context menu attached; the second one will have browser-default context menuRegards</description> <content:encoded><![CDATA[<p>Oh, dear, my HTML code got parsed&#8230;<br
/> What I wanted to say was:</p><p>imagine you have two spans: (I replaced &#8220;&#8221; with &#8220;@&#8221;)</p><p>@span class=&#8221;mif-tree-name&#8221;@ Click me @/span@<br
/> @span class=&#8221;some-class&#8221;@ Click me @/span@</p><p>Then if you do as described above, only the first span will have the JS context menu attached; the second one will have browser-default context menu</p><p>Regards</p> ]]></content:encoded> </item> <item><title>By: Nestor</title><link>http://davidwalsh.name/mootools-context-menu/comment-page-1#comment-17219</link> <dc:creator>Nestor</dc:creator> <pubDate>Thu, 22 Apr 2010 10:11:07 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-17219</guid> <description>Just figured out how to do that myself.Imagine our HTML document has the following two spans:
...
Click me
Click me
....in your initilaising javascript provide the target in the following format:targets: &#039;span.mif-tree-name&#039;, //menu only available on spans of classs mif-tree-namethen, modify your menu.js so that the &quot;startListener&quot; function is as follows://get things started
startListener: function() {
/* all elements */
this.targets.each(function(el) {
// =&gt; Array of links with given class. Provide target in the form: &#039;a.external&#039;, where &#039;external&#039; is a class name
matchingTargets = $$(el);
/* show the menu */
matchingTargets.addEvent(this.options.trigger,function(e) {
//enabled?
if(!this.options.disabled) {
//prevent default, if told to
if(this.options.stopEvent) { e.stop(); }
//record this as the trigger
this.options.element = $(el);
//position the menu
this.menu.setStyles({
top: (e.page.y + this.options.offsets.y),
left: (e.page.x + this.options.offsets.x),
position: &#039;absolute&#039;,
&#039;z-index&#039;: &#039;2000&#039;
});
//show the menu
this.show();
}
}.bind(this));
},this);
/* menu items */
this.menu.getElements(&#039;a&#039;).each(function(item) {
item.addEvent(&#039;click&#039;,function(e) {
if(!item.hasClass(&#039;disabled&#039;)) {
this.execute(item.get(&#039;href&#039;).split(&#039;#&#039;)[1],$(this.options.element));
this.fireEvent(&#039;click&#039;,[item,e]);
}
}.bind(this));
},this);
//hide on body click
$(document.body).addEvent(&#039;click&#039;, function() {
this.hide();
}.bind(this));
},All the magic is done in these few lines:/* all elements */
this.targets.each(function(el) {
// =&gt; Array of links with given class. Provide target in the form: &#039;a.external&#039;, where &#039;external&#039; is a class name
matchingTargets = $$(el);
/* show the menu */
matchingTargets.addEvent(this.options.trigger,function(e) {Enjoy!</description> <content:encoded><![CDATA[<p>Just figured out how to do that myself.</p><p>Imagine our HTML document has the following two spans:<br
/> &#8230;<br
/> Click me<br
/> Click me<br
/> &#8230;.</p><p>in your initilaising javascript provide the target in the following format:</p><p> targets: &#8216;span.mif-tree-name&#8217;, //menu only available on spans of classs mif-tree-name</p><p>then, modify your menu.js so that the &#8220;startListener&#8221; function is as follows:</p><p>//get things started<br
/> startListener: function() {<br
/> /* all elements */<br
/> this.targets.each(function(el) {<br
/> // =&gt; Array of links with given class. Provide target in the form: &#8216;a.external&#8217;, where &#8216;external&#8217; is a class name<br
/> matchingTargets = $$(el);<br
/> /* show the menu */<br
/> matchingTargets.addEvent(this.options.trigger,function(e) {<br
/> //enabled?<br
/> if(!this.options.disabled) {<br
/> //prevent default, if told to<br
/> if(this.options.stopEvent) { e.stop(); }<br
/> //record this as the trigger<br
/> this.options.element = $(el);<br
/> //position the menu<br
/> this.menu.setStyles({<br
/> top: (e.page.y + this.options.offsets.y),<br
/> left: (e.page.x + this.options.offsets.x),<br
/> position: &#8216;absolute&#8217;,<br
/> &#8216;z-index&#8217;: &#8217;2000&#8242;<br
/> });<br
/> //show the menu<br
/> this.show();<br
/> }<br
/> }.bind(this));<br
/> },this);</p><p> /* menu items */<br
/> this.menu.getElements(&#8216;a&#8217;).each(function(item) {<br
/> item.addEvent(&#8216;click&#8217;,function(e) {<br
/> if(!item.hasClass(&#8216;disabled&#8217;)) {<br
/> this.execute(item.get(&#8216;href&#8217;).split(&#8216;#&#8217;)[1],$(this.options.element));<br
/> this.fireEvent(&#8216;click&#8217;,[item,e]);<br
/> }<br
/> }.bind(this));<br
/> },this);</p><p> //hide on body click<br
/> $(document.body).addEvent(&#8216;click&#8217;, function() {<br
/> this.hide();<br
/> }.bind(this));<br
/> },</p><p>All the magic is done in these few lines:</p><p> /* all elements */<br
/> this.targets.each(function(el) {<br
/> // =&gt; Array of links with given class. Provide target in the form: &#8216;a.external&#8217;, where &#8216;external&#8217; is a class name<br
/> matchingTargets = $$(el);<br
/> /* show the menu */<br
/> matchingTargets.addEvent(this.options.trigger,function(e) {</p><p>Enjoy!</p> ]]></content:encoded> </item> <item><title>By: Nestor</title><link>http://davidwalsh.name/mootools-context-menu/comment-page-1#comment-17217</link> <dc:creator>Nestor</dc:creator> <pubDate>Thu, 22 Apr 2010 09:19:38 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-17217</guid> <description>Thanks for the plugin. That works magic. The only thing I would like to add is to being able to specify not only element type, but perhaps a class. For example, a page may have a myriad of links , but what if I only want to attach the menu to those belonging to a specific class, eg &lt;a href=&quot;#&quot; rel=&quot;nofollow&quot;&gt;...
How can I do that?
Thx again!</description> <content:encoded><![CDATA[<p>Thanks for the plugin. That works magic. The only thing I would like to add is to being able to specify not only element type, but perhaps a class. For example, a page may have a myriad of links , but what if I only want to attach the menu to those belonging to a specific class, eg <a
href="#" rel="nofollow">&#8230;<br
/> How can I do that?<br
/> Thx again!</a></p> ]]></content:encoded> </item> <item><title>By: Stanley Ngumo</title><link>http://davidwalsh.name/mootools-context-menu/comment-page-1#comment-17169</link> <dc:creator>Stanley Ngumo</dc:creator> <pubDate>Mon, 19 Apr 2010 14:32:56 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-17169</guid> <description>Hi,I havent tried it out but I would like to know if this menu can be initialized many times on one page on different objects i.e. on right click, a different menu (with varying links on it) based on which objects is right clicked.Thanx</description> <content:encoded><![CDATA[<p>Hi,</p><p>I havent tried it out but I would like to know if this menu can be initialized many times on one page on different objects i.e. on right click, a different menu (with varying links on it) based on which objects is right clicked.</p><p>Thanx</p> ]]></content:encoded> </item> <item><title>By: Alfred</title><link>http://davidwalsh.name/mootools-context-menu/comment-page-1#comment-13889</link> <dc:creator>Alfred</dc:creator> <pubDate>Tue, 24 Nov 2009 11:46:24 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-13889</guid> <description>LOL - Thanks - i see you answered same :-)</description> <content:encoded><![CDATA[<p>LOL &#8211; Thanks &#8211; i see you answered same :-)</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 7/19 queries in 0.027 seconds using disk

Served from: davidwalsh.name @ 2010-09-09 14:01:20 -->