<?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/"
xmlns:series="http://unfoldingneurons.com/"
> <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>Wed, 23 May 2012 13:59:49 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Wassilios Meletiadis</title><link>http://davidwalsh.name/mootools-context-menu#comment-26257</link> <dc:creator>Wassilios Meletiadis</dc:creator> <pubDate>Wed, 27 Jul 2011 10:54:06 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-26257</guid> <description>Damn! I&#039;ve forgotten to use the code-Tags. :(
Could you please fix my post for better readability. Thanks!</description> <content:encoded><![CDATA[<p>Damn! I&#8217;ve forgotten to use the code-Tags. :(<br
/> Could you please fix my post for better readability. Thanks!</p> ]]></content:encoded> </item> <item><title>By: Wassilios Meletiadis</title><link>http://davidwalsh.name/mootools-context-menu#comment-26256</link> <dc:creator>Wassilios Meletiadis</dc:creator> <pubDate>Wed, 27 Jul 2011 10:52:24 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-26256</guid> <description>Very nice plugin!I needed the ability to define my own z-index for the contextmenu. Therefore I made the
following changes:var ContextMenu = new Class({
options: {
actions: {},
...
fadeSpeed: 200,                             // don&#039;t forget to add a comma
// somewhere near line 29
zIndex : 2000                               // set the default z-index
},
......
startListener: function() {
this.targets.each(function(el) {
...this.menu.setStyles({
...
position: &#039;absolute&#039;,               // don&#039;t forget to add a comma
// somewhere near line 67
&#039;z-index&#039;: this.options.zIndex      // apply the z-index
});
...
}
}
});After doing these changes one can do this:new ContextMenu({
actions : {
...
},
...
zIndex : 3000
});</description> <content:encoded><![CDATA[<p>Very nice plugin!</p><p>I needed the ability to define my own z-index for the contextmenu. Therefore I made the<br
/> following changes:</p><p>var ContextMenu = new Class({<br
/> options: {<br
/> actions: {},<br
/> &#8230;<br
/> fadeSpeed: 200,                             // don&#8217;t forget to add a comma<br
/> // somewhere near line 29<br
/> zIndex : 2000                               // set the default z-index<br
/> },<br
/> &#8230;</p><p> &#8230;<br
/> startListener: function() {<br
/> this.targets.each(function(el) {<br
/> &#8230;</p><p> this.menu.setStyles({<br
/> &#8230;<br
/> position: &#8216;absolute&#8217;,               // don&#8217;t forget to add a comma<br
/> // somewhere near line 67<br
/> &#8216;z-index&#8217;: this.options.zIndex      // apply the z-index<br
/> });<br
/> &#8230;<br
/> }<br
/> }<br
/> });</p><p>After doing these changes one can do this:</p><p>new ContextMenu({<br
/> actions : {<br
/> &#8230;<br
/> },<br
/> &#8230;<br
/> zIndex : 3000<br
/> });</p> ]]></content:encoded> </item> <item><title>By: Niklas Lehto</title><link>http://davidwalsh.name/mootools-context-menu#comment-23358</link> <dc:creator>Niklas Lehto</dc:creator> <pubDate>Tue, 05 Apr 2011 02:32:59 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-23358</guid> <description>The context menu is not to blame for breaking the sortable class. There&#039;s a bug in v1.2.4.4 of the sortables class itself.For details and a solution, check out https://mootools.lighthouseapp.com/projects/24057/tickets/292-sortables-breaking-on-right-clicking-mouse-button2-the-handleGood luck!</description> <content:encoded><![CDATA[<p>The context menu is not to blame for breaking the sortable class. There&#8217;s a bug in v1.2.4.4 of the sortables class itself.</p><p>For details and a solution, check out <a
href="https://mootools.lighthouseapp.com/projects/24057/tickets/292-sortables-breaking-on-right-clicking-mouse-button2-the-handle" rel="nofollow">https://mootools.lighthouseapp.com/projects/24057/tickets/292-sortables-breaking-on-right-clicking-mouse-button2-the-handle</a></p><p>Good luck!</p> ]]></content:encoded> </item> <item><title>By: Nestor</title><link>http://davidwalsh.name/mootools-context-menu#comment-23202</link> <dc:creator>Nestor</dc:creator> <pubDate>Tue, 22 Mar 2011 10:27:18 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-23202</guid> <description>I suggest using the &quot;name&quot; attribute instead of the &quot;href&quot; on the link to avoid the &quot;#action&quot; being addded to the url. Easy fix, as follows:In your HTML :&lt;a&gt;Edit&lt;/a&gt;
&lt;a&gt;Cut&lt;/a&gt;
&lt;a&gt;Copy&lt;/a&gt;
&lt;a&gt;Paste&lt;/a&gt;
&lt;a&gt;Delete&lt;/a&gt;
&lt;a&gt;Quit&lt;/a&gt;then in line 68 0f the script:/* 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;name&#039;),$(this.options.element));
this.fireEvent(&#039;click&#039;,[item,e]);
}
}.bind(this));
},this);Enjoy!</description> <content:encoded><![CDATA[<p>I suggest using the &#8220;name&#8221; attribute instead of the &#8220;href&#8221; on the link to avoid the &#8220;#action&#8221; being addded to the url. Easy fix, as follows:</p><p>In your HTML :</p><p> <a>Edit</a><br
/> <a>Cut</a><br
/> <a>Copy</a><br
/> <a>Paste</a><br
/> <a>Delete</a><br
/> <a>Quit</a></p><p>then in line 68 0f the script:</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;name&#8217;),$(this.options.element));<br
/> this.fireEvent(&#8216;click&#8217;,[item,e]);<br
/> }<br
/> }.bind(this));<br
/> },this);</p><p>Enjoy!</p> ]]></content:encoded> </item> <item><title>By: Greg Clout</title><link>http://davidwalsh.name/mootools-context-menu#comment-22842</link> <dc:creator>Greg Clout</dc:creator> <pubDate>Wed, 23 Feb 2011 22:24:28 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-22842</guid> <description>Fantastic component!
The only trouble im having at present is that the click event is conflicting with the sortables class.
After opening the menu I can no loger drag and drop in my sortable lists.</description> <content:encoded><![CDATA[<p>Fantastic component!<br
/> The only trouble im having at present is that the click event is conflicting with the sortables class.<br
/> After opening the menu I can no loger drag and drop in my sortable lists.</p> ]]></content:encoded> </item> <item><title>By: Roman</title><link>http://davidwalsh.name/mootools-context-menu#comment-21064</link> <dc:creator>Roman</dc:creator> <pubDate>Thu, 21 Oct 2010 18:42:01 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-21064</guid> <description>Hello folksThe following code works fine for me to reinitialize the context menu:&lt;code&gt;
context.targets.removeEvents(&#039;contextmenu&#039;);
context.targets = $$(&#039;.myNewTargets&#039;);
context.menu.getElements(&#039;a&#039;).removeEvents(&#039;click&#039;);
context.startListener();&lt;/code&gt;</description> <content:encoded><![CDATA[<p>Hello folks</p><p>The following code works fine for me to reinitialize the context menu:</p><p><code><br
/> context.targets.removeEvents('contextmenu');<br
/> context.targets = $$('.myNewTargets');<br
/> context.menu.getElements('a').removeEvents('click');<br
/> context.startListener();</code></p> ]]></content:encoded> </item> <item><title>By: Ann</title><link>http://davidwalsh.name/mootools-context-menu#comment-21026</link> <dc:creator>Ann</dc:creator> <pubDate>Sun, 17 Oct 2010 08:13:15 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=966#comment-21026</guid> <description>fuction contextdemo()
{
alert(&quot;hi&quot;);
var menu=contextMenu.createElement(&#039;menu&#039;);
var itemNode=contextMenu.createElement(&#039;item&#039;);
var itemtext=contextMenu.createTextNode(&quot;search&quot;);
var itemattr=contextMenu.createAttribute(&#039;onactivate&#039;);
itemtext.appendChild(itemattr);
itemNode.appendChild(itemtext);
menu.appendChild(itemNode);}</description> <content:encoded><![CDATA[<p>fuction contextdemo()<br
/> {<br
/> alert(&#8220;hi&#8221;);<br
/> var menu=contextMenu.createElement(&#8216;menu&#8217;);<br
/> var itemNode=contextMenu.createElement(&#8216;item&#8217;);<br
/> var itemtext=contextMenu.createTextNode(&#8220;search&#8221;);<br
/> var itemattr=contextMenu.createAttribute(&#8216;onactivate&#8217;);<br
/> itemtext.appendChild(itemattr);<br
/> itemNode.appendChild(itemtext);<br
/> menu.appendChild(itemNode);</p><p>}</p> ]]></content:encoded> </item> <item><title>By: Niklas Lehto</title><link>http://davidwalsh.name/mootools-context-menu#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-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-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> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 3/7 queries in 0.007 seconds using disk: basic
Object Caching 805/805 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-23 09:01:22 -->
