<?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: Drag. Drop.&#160;Lock.</title> <atom:link href="http://davidwalsh.name/mootools-drag-drop-lock/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/mootools-drag-drop-lock</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Wed, 23 May 2012 14:01:31 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Patrick</title><link>http://davidwalsh.name/mootools-drag-drop-lock#comment-21044</link> <dc:creator>Patrick</dc:creator> <pubDate>Tue, 19 Oct 2010 20:16:35 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=249#comment-21044</guid> <description>GREAT Site! You are one of the first sites I read every morning I get going.Quick Question: Can you force an item to be in a droppable location on page load ... if for instance I wanted to load the selections a person made previously via a recordset ... and drop their selections where they ended up. Is there a way to do that?Thanks!- Patrick</description> <content:encoded><![CDATA[<p>GREAT Site! You are one of the first sites I read every morning I get going.</p><p>Quick Question: Can you force an item to be in a droppable location on page load &#8230; if for instance I wanted to load the selections a person made previously via a recordset &#8230; and drop their selections where they ended up. Is there a way to do that?</p><p>Thanks!</p><p>- Patrick</p> ]]></content:encoded> </item> <item><title>By: Arvind</title><link>http://davidwalsh.name/mootools-drag-drop-lock#comment-19822</link> <dc:creator>Arvind</dc:creator> <pubDate>Thu, 09 Sep 2010 15:01:56 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=249#comment-19822</guid> <description>I just wanted to say thanks for the IE hack in the code above!&lt;code&gt;
document.ondragstart = function () { return false; }; //IE drag hack
&lt;/code&gt;I wanted to make the draggables have an anchor element only so that the user would be able to use TAB to step to the draggable for keyboard accessibility.
&lt;code&gt;
&lt;a href=&quot;#&quot; rel=&quot;nofollow&quot;&gt;&lt;/a&gt;
&lt;/code&gt;That works fine in FF but not in IE7. Applying the above hack solves the problem nicely!Thanks!/Arvind</description> <content:encoded><![CDATA[<p>I just wanted to say thanks for the IE hack in the code above!</p><p><code><br
/> document.ondragstart = function () { return false; }; //IE drag hack<br
/> </code></p><p>I wanted to make the draggables have an anchor element only so that the user would be able to use TAB to step to the draggable for keyboard accessibility.<br
/> <code><br
/> <a
href="#" rel="nofollow"></a><br
/> </code></p><p>That works fine in FF but not in IE7. Applying the above hack solves the problem nicely!</p><p>Thanks!</p><p>/Arvind</p> ]]></content:encoded> </item> <item><title>By: Sebastien</title><link>http://davidwalsh.name/mootools-drag-drop-lock#comment-17740</link> <dc:creator>Sebastien</dc:creator> <pubDate>Thu, 20 May 2010 19:19:46 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=249#comment-17740</guid> <description>Will this work with jQuery?</description> <content:encoded><![CDATA[<p>Will this work with jQuery?</p> ]]></content:encoded> </item> <item><title>By: visu</title><link>http://davidwalsh.name/mootools-drag-drop-lock#comment-17480</link> <dc:creator>visu</dc:creator> <pubDate>Sat, 08 May 2010 10:06:12 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=249#comment-17480</guid> <description>Hi David,Excellent example. In my use case i have the elements which are draggable as well as droppable. so i am having the same class for all the elements.When we drag an element from top to bottom in forward direction, it&#039;s working fine. In the OnEnter method of Drag.Move, we can find out both draggable element and the entered droppable element.But the reverse is not happening. Means when we drag any element in reverse direction that is from bottom to top, in the onEnter method i am getting the same element for both draggable and droppable.i am using css position relative for the div&#039;s.Can someone help me how to handle this.Thanks
Visu</description> <content:encoded><![CDATA[<p>Hi David,</p><p> Excellent example. In my use case i have the elements which are draggable as well as droppable. so i am having the same class for all the elements.</p><p>When we drag an element from top to bottom in forward direction, it&#8217;s working fine. In the OnEnter method of Drag.Move, we can find out both draggable element and the entered droppable element.</p><p>But the reverse is not happening. Means when we drag any element in reverse direction that is from bottom to top, in the onEnter method i am getting the same element for both draggable and droppable.</p><p>i am using css position relative for the div&#8217;s.</p><p>Can someone help me how to handle this.</p><p>Thanks<br
/> Visu</p> ]]></content:encoded> </item> <item><title>By: Grrreat</title><link>http://davidwalsh.name/mootools-drag-drop-lock#comment-16002</link> <dc:creator>Grrreat</dc:creator> <pubDate>Tue, 09 Feb 2010 00:14:32 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=249#comment-16002</guid> <description>LoL vanquybn  why don&#039;t you post your whole website and David can sort out all your errors.By the way for those wanting the ghost drag thing check out this sitehttp://www.monkeyphysics.com/mootools/script/1/dragghost</description> <content:encoded><![CDATA[<p>LoL vanquybn  why don&#8217;t you post your whole website and David can sort out all your errors.</p><p>By the way for those wanting the ghost drag thing check out this site</p><p><a
href="http://www.monkeyphysics.com/mootools/script/1/dragghost" rel="nofollow">http://www.monkeyphysics.com/mootools/script/1/dragghost</a></p> ]]></content:encoded> </item> <item><title>By: vanquybn</title><link>http://davidwalsh.name/mootools-drag-drop-lock#comment-14948</link> <dc:creator>vanquybn</dc:creator> <pubDate>Sat, 02 Jan 2010 05:40:05 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=249#comment-14948</guid> <description>can you help me convert this file to mootools 1.2.x
please help me. thanks!.var src_collap_1 = tmplurl + &quot;/images/icon-min.gif&quot;;
var src_collap_2 = tmplurl + &quot;/images/icon-max.gif&quot;;
new Asset.images ([src_collap_1, src_collap_2]);
function testfunc () {
alert(&#039;fdsf&#039;);
}
var JADDModules = new Class({options: {
handles: false,
containers: false,
onStart: Class.empty,
onComplete: Class.empty,
ghost: true,
snap: 3,
title: &#039;h3&#039;,
src_collap_1:&#039;&#039;,
src_collap_2:&#039;&#039;,
onDragStart: function(element, ghost){
ghost.setStyles({&#039;opacity&#039;:0.7, &#039;z-index&#039;:100});
element.getChildren().setStyles({&#039;opacity&#039;:0.3, &#039;z-index&#039;:1});
element.addClass(&#039;moving&#039;);
},
onDragComplete: function(element, ghost){
element.getChildren().setStyle(&#039;opacity&#039;, 1);
element.removeClass(&#039;moving&#039;);
ghost.remove();
this.trash.remove();
}
},initialize: function(lists, options){
//console.log(encodeURIComponent(&quot;h%E1%BB%93ng%20c%C3%B4ng&quot;));
this.setOptions(options);
this.lists = $$(lists);
this.lists.sort(function(a,b){return a.getCoordinates().left - b.getCoordinates().left;});
this.elements = [];
this.handles = [];
/*	Get cookies	*/
this.hc = &#039;&#039;;
if(Cookie.get(&#039;ja-ordercolumn&#039;)){
this.hc = Cookie.get(&#039;ja-ordercolumn&#039;).split(&#039;,&#039;);
if(this.hc!=&#039;&#039;){
this.hc.each(function(cc,k){
this.hc[k] = this.hc[k].split(&quot;_&quot;);
},this);
}
}
this.lists.each(function(list){
var elements = list.getChildren();
elements.each(function(el,i){
el._p = list;
if(this.options.title){
el._h = $E(this.options.title, el);
if (!el._h) return;
tmp = el._h.getParent();
el._h.remove();
tmp.innerHTML = &quot;&quot;+tmp.innerHTML+&quot;&quot;;
el._innerdiv = tmp.getFirst();
el._h.injectTop (tmp);
//el._h._el = el;
el._pos = i;
if(this.hc){
//element property: position, container, ...
this.hc.each(function(val){
if (val[1] == el._h.innerHTML.trim().substr(0,20)) {
el._p 			= $(val[0]);
el._pos 		= parseInt(val[2]);
el._h.className	= val[3];
}
},this);
}
if(el._h.className==&quot;hide&quot;){
src_collap = this.options.src_collap_1;
}
else{
el._h.className = &#039;show&#039;;
src_collap = this.options.src_collap_2;
}
//create handler for moveable and collapsible hotspot
divmd = new Element(&#039;span&#039;,{&#039;class&#039;:&#039;ja-mdtool&#039;});
divmd.inject(el._h);
chdl = new Element(&#039;img&#039;,{&#039;src&#039;:src_collap});
chdl.setStyle(&#039;cursor&#039;,&#039;pointer&#039;);
chdl.inject (divmd);
el._h._chdl = chdl;
this.handles.push(el._h);
}
},this);this.elements.merge(elements);
this.lists.setStyle(&#039;visibility&#039;,&#039;visible&#039;);
},this);
this.elements.each (function (el){
el.remove();
p = $(el._p);
if(!p) return ;
tmp = p.getChildren().length &gt; el._pos ? p.getChildren()[el._pos]:null;
if (tmp) {
if (tmp._pos &gt; el._pos) el.injectBefore(tmp);
else el.injectAfter(tmp);
}
else el.inject (p);
});
//this.elements = $$(list);
this.handles = (this.options.handles) ? $$(this.options.handles) : (this.handles.length?this.handles:this.elements);
//this.handles.setStyle(&#039;cursor&#039;, &#039;move&#039;);
this.bound = {
&#039;start&#039;: [],
&#039;moveGhost&#039;: this.moveGhost.bindWithEvent(this)
};
for (var i = 0, l = this.handles.length; i &lt; l; i++){
this.bound.start[i] = this.start.bindWithEvent(this, this.elements[i]);
}
this.attach();
this.collap();
if (this.options.initialize) this.options.initialize.call(this);
this.bound.move = this.move.bindWithEvent(this);
this.bound.end = this.end.bind(this);
if (window.opera) window.addEvent(&quot;unload&quot;, this.saveCookies.bind(this));
else window.addEvent(&quot;beforeunload&quot;, this.saveCookies.bind(this));},collap: function(){
this.lists.each(function(list){
var elements = list.getChildren();
elements.each(function(el,i){
/*	For collap		*/
el.elmain = $E(&#039;.ja-mod-content&#039;,el);
if(!el._h) return;el.maxH = el.elmain.getStyle(&#039;height&#039;).toInt();
el.elmain.setStyle (&#039;overflow&#039;,&#039;hidden&#039;);
el._h._chdl.addEvent(&#039;mousedown&#039;, function(e){
e = new Event(e).stop();
});
el._h._chdl.addEvent(&#039;click&#039;, function(e){
e = new Event(e).stop();
el.toggle();
});
el.toggle = function(){
if (el._h.className==&#039;hide&#039;){
el.show();
}
else el.hide();
}
el.show = function() {
el._h.className=&#039;show&#039;;
el._h._chdl.src = src_collap_2;
new Fx.Style(el.elmain,&#039;height&#039;,{onComplete:el.toggleStatuss}).start(el.elmain.offsetHeight,el.elmain.scrollHeight);
}
el.hide = function() {
el._h.className=&#039;hide&#039;;
el._h._chdl.src = src_collap_1;
new Fx.Style(el.elmain,&#039;height&#039;,{onComplete:el.toggleStatuss}).start(el.elmain.offsetHeight,0);
}
el.toggleStatuss = function () {
el._status=(el._status==&#039;hide&#039;)?&#039;show&#039;:&#039;hide&#039;;
}
if(el._h.className==&#039;hide&#039;) {
el.hide();
}
else{
el.show();
}
}, this);
}, this);
},
attach: function(){
this.handles.each(function(handle, i){
//handle.addEvent(&#039;mousedown&#039;, this.bound.start[i]);
handle.addEvent(&#039;mousedown&#039;, this.bound.start[i]);
handle.setStyle(&#039;cursor&#039;,&#039;move&#039;);
}, this);
},detach: function(){
this.handles.each(function(handle, i){
handle.removeEvent(&#039;mousedown&#039;, this.bound.start[i]);
}, this);
},start: function(event, el){
this.active = el;
//this.coordinates = this.list.getCoordinates();
if (this.options.ghost){
this.previous = 0;
var position = el.getPosition();
this.offsetX = event.page.x - position.x;
this.offsetY = event.page.y - position.y;
this.trash = new Element(&#039;div&#039;).inject(document.body);
this.ghost = el.clone().inject(this.trash).setStyles({
&#039;position&#039;: &#039;absolute&#039;,
&#039;left&#039;: event.page.x - this.offsetX,
&#039;top&#039;: event.page.y - this.offsetY,
&#039;background&#039;:&#039;url(../images/box-br.gif) no-repeat bottom right #444444&#039;,
&#039;width&#039;: el.offsetWidth
});document.addListener(&#039;mousemove&#039;, this.bound.moveGhost);
this.fireEvent(&#039;onDragStart&#039;, [el, this.ghost]);
}
document.addListener(&#039;mousemove&#039;, this.bound.move);
document.addListener(&#039;mouseup&#039;, this.bound.end);
this.fireEvent(&#039;onStart&#039;, el);
event.stop();
},moveGhost: function(event){
this.ghost.setStyles({&#039;left&#039;: event.page.x-this.offsetX,
&#039;top&#039;: event.page.y-this.offsetY
});
event.stop();
},move: function(event){
var cor = this.active.getCoordinates();
if(cor.left &lt; event.page.x &amp;&amp; event.page.x  cor.top &amp;&amp; event.page.y  list.getCoordinates().left) clist = list;
}, this);
if(clist == this.active._p) {
var now = event.page.y;
this.previous = this.previous &#124;&#124; now;
var up = ((this.previous - now) &gt; 0);
var prev = this.active.getPrevious();
var next = this.active.getNext();
if (prev &amp;&amp; up &amp;&amp; now  next._h.getCoordinates().top) this.active.injectAfter(next);
this.previous = now;
}else{
var now = event.page.y;
//Get correct position
var els = clist.getChildren();
if(els.length) {
var cel = els[0];
els.each(function(el, idx){
if (now &gt; el._h.getCoordinates().bottom)
{
if(idx &lt; els.length - 1) cel = els[idx+1];
else cel = null;
}
},this);if(cel) this.active.injectBefore(cel);
else this.active.inject(clist);
} else {
this.active.inject(clist);
}
this.active._p = clist;
this.previous = now;
}},serialize: function(converter){
return this.list.getChildren().map(converter &#124;&#124; function(el){
return this.elements.indexOf(el);
}, this);
},end: function(){
this.previous = null;
document.removeListener(&#039;mousemove&#039;, this.bound.move);
document.removeListener(&#039;mouseup&#039;, this.bound.end);
if (this.options.ghost){
document.removeListener(&#039;mousemove&#039;, this.bound.moveGhost);
this.fireEvent(&#039;onDragComplete&#039;, [this.active, this.ghost]);
}
this.fireEvent(&#039;onComplete&#039;, this.active);
},
saveCookies: function() {
if (Cookie.get(&quot;ja-ordercolumn&quot;) == &#039;-&#039;) {
Cookie.set(&quot;ja-ordercolumn&quot;, &#039;&#039;,{path:&#039;/&#039;});
return;
}
c = &#039;&#039;;
this.lists.each(function(list){
var elements = list.getChildren();
if (!elements){
return;
}
elements.each(function(el,i){
c += el._p.id + &quot;_&quot; + el._h.innerHTML.trim().substr(0,20) + &quot;_&quot; + i + &quot;_&quot; + el._h.className+&quot;,&quot;;
},this);
},this);
if (this.hc) {
this.hc.each(function(value, k){
if (!c.test (&#039;_&#039; + value[1] + &#039;_&#039;)) {
c += value[0] + &quot;_&quot; + value[1] + &quot;_&quot; + value[2] + &quot;_&quot; + value[3]+&quot;,&quot;;
}
},this);
}
c = c.substr(0, (c.length-1));
Cookie.set(&quot;ja-ordercolumn&quot;, c, {duration: 365,path:&#039;/&#039;});
}
});document.write(&#039;.ja-movable-container{visibility: hidden;}&#039;);
window.addEvent(&#039;load&#039;, function(){
new JADDModules($$(&quot;.ja-movable-container&quot;), {src_collap_1:src_collap_1, src_collap_2:src_collap_2});
});JADDModules.implement(new Events, new Options);JAResizer = new Class({
initialize: function(els, options){
this.options = Object.extend({
min: 100,
max: 0
}, options &#124;&#124; {});
$$(els).each(function(el){
el.onmouseover = function(){
this.addClass(&#039;ja-colresizehover&#039;);
};
resizemouseout = function(){
//console.log(&#039;call mouse out event for &#039; + this);
this.removeClass(&#039;ja-colresizehover&#039;);
}
el.onmouseout = resizemouseout;var prev = el.getPrevious();
var next = el.getNext();
prev.makeResizableNew ({handle: el, modifiers:{y:false}, limit:{width:[100]}});
next.makeResizableNew ({handle: el, modifiers:{y:false}, dir: -1, limit:{width:[100]}});
var eld = el.makeDraggable({modifiers:{y:false}});eld.addEvent(&#039;onStart&#039;, function (el) {
//console.log(&#039;Remove mouse out for &#039; + eld.element);
el.onmouseout = null;
this._next = el.getNext();
this._prev = el.getPrevious();
this._w = this._prev.getStyle(&#039;width&#039;).toFloat() + this._next.getStyle(&#039;width&#039;).toFloat();
});eld.addEvent(&#039;onComplete&#039;, function (el) {
el.onmouseout = resizemouseout;var w1 = this._prev.offsetWidth;
var w2 = this._next.offsetWidth;
var w1p = w1/(w1+w2)*this._w;
var w2p = w2/(w1+w2)*this._w;
var elwp = el.offsetLeft * this._w / (w1+w2);
this._prev.setStyle(&#039;width&#039;, w1p + &#039;%&#039;);
this._next.setStyle(&#039;width&#039;, w2p + &#039;%&#039;);
el.setStyle (&#039;left&#039;, elwp + &#039;%&#039;);el = el.getCoordinates(this.options.overflown);
var now = this.mouse.now;
if (!(now.x &gt; el.left &amp;&amp; now.x &lt; el.right &amp;&amp; now.y  el.top)) resizemouseout.call(this.element);});
}.bind( this));
}
});Drag.Resize = Drag.Base.extend({options: {
dir: 1
},initialize: function(el, options){
this.setOptions(options);
this.parent(el);
},start: function(event){
this.fireEvent(&#039;onBeforeStart&#039;, this.element);
this.mouse.start = event.page;
var limit = this.options.limit;
this.limit = {&#039;x&#039;: [], &#039;y&#039;: []};
for (var z in this.options.modifiers){
if (!this.options.modifiers[z]) continue;
this.value.now[z] = this.element.getCoordinates()[this.options.modifiers[z]].toInt();
this.mouse.pos[z] = event.page[z] - this.value.now[z]*this.options.dir;
if (limit &amp;&amp; limit[z]){
for (var i = 0; i  this.limit[z][1])){
this.value.now[z] = this.limit[z][1];
this.out = true;
} else if ($chk(this.limit[z][0]) &amp;&amp; (this.value.now[z] &lt; this.limit[z][0])){
this.value.now[z] = this.limit[z][0];
this.out = true;
}
}
if (this.options.grid[z]) this.value.now[z] -= (this.value.now[z] % this.options.grid[z]);
this.element.setStyle(this.options.modifiers[z], this.value.now[z] + this.options.unit);
}
this.fireEvent(&#039;onDrag&#039;, this.element);
event.stop();
}});/*
Class: Element
Custom class to allow all of its methods to be used with any DOM element via the dollar function .
*/Element.extend({/*
Property: makeDraggable
Makes an element draggable with the supplied options.Arguments:
options - see  and  for acceptable options.
*/makeResizableNew: function(options){
return new Drag.Resize(this, $merge({modifiers: {x: &#039;width&#039;, y: &#039;height&#039;}}, options));
}});This works in mootools 1.12, but not work in 1.2.x, please help me</description> <content:encoded><![CDATA[<p>can you help me convert this file to mootools 1.2.x<br
/> please help me. thanks!.</p><p>var src_collap_1 = tmplurl + &#8220;/images/icon-min.gif&#8221;;<br
/> var src_collap_2 = tmplurl + &#8220;/images/icon-max.gif&#8221;;<br
/> new Asset.images ([src_collap_1, src_collap_2]);<br
/> function testfunc () {<br
/> alert(&#8216;fdsf&#8217;);<br
/> }<br
/> var JADDModules = new Class({</p><p> options: {<br
/> handles: false,<br
/> containers: false,<br
/> onStart: Class.empty,<br
/> onComplete: Class.empty,<br
/> ghost: true,<br
/> snap: 3,<br
/> title: &#8216;h3&#8242;,<br
/> src_collap_1:&#8221;,<br
/> src_collap_2:&#8221;,</p><p> onDragStart: function(element, ghost){<br
/> ghost.setStyles({&#8216;opacity&#8217;:0.7, &#8216;z-index&#8217;:100});<br
/> element.getChildren().setStyles({&#8216;opacity&#8217;:0.3, &#8216;z-index&#8217;:1});<br
/> element.addClass(&#8216;moving&#8217;);<br
/> },<br
/> onDragComplete: function(element, ghost){<br
/> element.getChildren().setStyle(&#8216;opacity&#8217;, 1);<br
/> element.removeClass(&#8216;moving&#8217;);<br
/> ghost.remove();<br
/> this.trash.remove();<br
/> }<br
/> },</p><p> initialize: function(lists, options){<br
/> //console.log(encodeURIComponent(&#8220;h%E1%BB%93ng%20c%C3%B4ng&#8221;));<br
/> this.setOptions(options);<br
/> this.lists = $$(lists);<br
/> this.lists.sort(function(a,b){return a.getCoordinates().left &#8211; b.getCoordinates().left;});<br
/> this.elements = [];<br
/> this.handles = [];</p><p> /*	Get cookies	*/<br
/> this.hc = &#8221;;<br
/> if(Cookie.get(&#8216;ja-ordercolumn&#8217;)){<br
/> this.hc = Cookie.get(&#8216;ja-ordercolumn&#8217;).split(&#8216;,&#8217;);<br
/> if(this.hc!=&#8221;){<br
/> this.hc.each(function(cc,k){<br
/> this.hc[k] = this.hc[k].split(&#8220;_&#8221;);<br
/> },this);<br
/> }<br
/> }</p><p> this.lists.each(function(list){<br
/> var elements = list.getChildren();<br
/> elements.each(function(el,i){<br
/> el._p = list;<br
/> if(this.options.title){<br
/> el._h = $E(this.options.title, el);<br
/> if (!el._h) return;<br
/> tmp = el._h.getParent();<br
/> el._h.remove();<br
/> tmp.innerHTML = &#8220;&#8221;+tmp.innerHTML+&#8221;";<br
/> el._innerdiv = tmp.getFirst();<br
/> el._h.injectTop (tmp);<br
/> //el._h._el = el;</p><p> el._pos = i;</p><p> if(this.hc){<br
/> //element property: position, container, &#8230;<br
/> this.hc.each(function(val){<br
/> if (val[1] == el._h.innerHTML.trim().substr(0,20)) {<br
/> el._p 			= $(val[0]);<br
/> el._pos 		= parseInt(val[2]);<br
/> el._h.className	= val[3];<br
/> }<br
/> },this);<br
/> }</p><p> if(el._h.className==&#8221;hide&#8221;){<br
/> src_collap = this.options.src_collap_1;<br
/> }<br
/> else{<br
/> el._h.className = &#8216;show&#8217;;<br
/> src_collap = this.options.src_collap_2;<br
/> }</p><p> //create handler for moveable and collapsible hotspot<br
/> divmd = new Element(&#8216;span&#8217;,{&#8216;class&#8217;:'ja-mdtool&#8217;});<br
/> divmd.inject(el._h);<br
/> chdl = new Element(&#8216;img&#8217;,{&#8216;src&#8217;:src_collap});<br
/> chdl.setStyle(&#8216;cursor&#8217;,'pointer&#8217;);<br
/> chdl.inject (divmd);<br
/> el._h._chdl = chdl;</p><p> this.handles.push(el._h);<br
/> }<br
/> },this);</p><p> this.elements.merge(elements);</p><p> this.lists.setStyle(&#8216;visibility&#8217;,'visible&#8217;);</p><p> },this);</p><p> this.elements.each (function (el){</p><p> el.remove();<br
/> p = $(el._p);<br
/> if(!p) return ;<br
/> tmp = p.getChildren().length &gt; el._pos ? p.getChildren()[el._pos]:null;<br
/> if (tmp) {<br
/> if (tmp._pos &gt; el._pos) el.injectBefore(tmp);<br
/> else el.injectAfter(tmp);<br
/> }<br
/> else el.inject (p);</p><p> });</p><p> //this.elements = $$(list);<br
/> this.handles = (this.options.handles) ? $$(this.options.handles) : (this.handles.length?this.handles:this.elements);<br
/> //this.handles.setStyle(&#8216;cursor&#8217;, &#8216;move&#8217;);<br
/> this.bound = {<br
/> &#8216;start&#8217;: [],<br
/> &#8216;moveGhost&#8217;: this.moveGhost.bindWithEvent(this)<br
/> };<br
/> for (var i = 0, l = this.handles.length; i &lt; l; i++){<br
/> this.bound.start[i] = this.start.bindWithEvent(this, this.elements[i]);<br
/> }</p><p> this.attach();<br
/> this.collap();</p><p> if (this.options.initialize) this.options.initialize.call(this);<br
/> this.bound.move = this.move.bindWithEvent(this);<br
/> this.bound.end = this.end.bind(this);</p><p> if (window.opera) window.addEvent(&quot;unload&quot;, this.saveCookies.bind(this));<br
/> else window.addEvent(&quot;beforeunload&quot;, this.saveCookies.bind(this));</p><p> },</p><p> collap: function(){<br
/> this.lists.each(function(list){<br
/> var elements = list.getChildren();<br
/> elements.each(function(el,i){<br
/> /*	For collap		*/</p><p> el.elmain = $E(&#039;.ja-mod-content&#039;,el);<br
/> if(!el._h) return;</p><p> el.maxH = el.elmain.getStyle(&#039;height&#039;).toInt();</p><p> el.elmain.setStyle (&#039;overflow&#039;,&#039;hidden&#039;);</p><p> el._h._chdl.addEvent(&#039;mousedown&#039;, function(e){<br
/> e = new Event(e).stop();<br
/> });<br
/> el._h._chdl.addEvent(&#039;click&#039;, function(e){<br
/> e = new Event(e).stop();<br
/> el.toggle();<br
/> });</p><p> el.toggle = function(){<br
/> if (el._h.className==&#039;hide&#039;){<br
/> el.show();<br
/> }<br
/> else el.hide();<br
/> }</p><p> el.show = function() {<br
/> el._h.className=&#039;show&#039;;<br
/> el._h._chdl.src = src_collap_2;<br
/> new Fx.Style(el.elmain,&#039;height&#039;,{onComplete:el.toggleStatuss}).start(el.elmain.offsetHeight,el.elmain.scrollHeight);<br
/> }<br
/> el.hide = function() {<br
/> el._h.className=&#039;hide&#039;;<br
/> el._h._chdl.src = src_collap_1;<br
/> new Fx.Style(el.elmain,&#039;height&#039;,{onComplete:el.toggleStatuss}).start(el.elmain.offsetHeight,0);<br
/> }<br
/> el.toggleStatuss = function () {<br
/> el._status=(el._status==&#039;hide&#039;)?&#039;show&#039;:&#039;hide&#039;;<br
/> }</p><p> if(el._h.className==&#039;hide&#039;) {<br
/> el.hide();<br
/> }<br
/> else{<br
/> el.show();<br
/> }</p><p> }, this);<br
/> }, this);<br
/> },</p><p> attach: function(){<br
/> this.handles.each(function(handle, i){<br
/> //handle.addEvent(&#039;mousedown&#039;, this.bound.start[i]);<br
/> handle.addEvent(&#039;mousedown&#039;, this.bound.start[i]);<br
/> handle.setStyle(&#039;cursor&#039;,&#039;move&#039;);<br
/> }, this);<br
/> },</p><p> detach: function(){<br
/> this.handles.each(function(handle, i){<br
/> handle.removeEvent(&#039;mousedown&#039;, this.bound.start[i]);<br
/> }, this);<br
/> },</p><p> start: function(event, el){<br
/> this.active = el;<br
/> //this.coordinates = this.list.getCoordinates();<br
/> if (this.options.ghost){<br
/> this.previous = 0;<br
/> var position = el.getPosition();<br
/> this.offsetX = event.page.x &#8211; position.x;<br
/> this.offsetY = event.page.y &#8211; position.y;<br
/> this.trash = new Element(&#039;div&#039;).inject(document.body);</p><p> this.ghost = el.clone().inject(this.trash).setStyles({<br
/> &#039;position&#039;: &#039;absolute&#039;,<br
/> &#039;left&#039;: event.page.x &#8211; this.offsetX,<br
/> &#039;top&#039;: event.page.y &#8211; this.offsetY,<br
/> &#039;background&#039;:&#039;url(../images/box-br.gif) no-repeat bottom right #444444&#039;,<br
/> &#039;width&#039;: el.offsetWidth<br
/> });</p><p> document.addListener(&#039;mousemove&#039;, this.bound.moveGhost);<br
/> this.fireEvent(&#039;onDragStart&#039;, [el, this.ghost]);<br
/> }<br
/> document.addListener(&#039;mousemove&#039;, this.bound.move);<br
/> document.addListener(&#039;mouseup&#039;, this.bound.end);<br
/> this.fireEvent(&#039;onStart&#039;, el);<br
/> event.stop();<br
/> },</p><p> moveGhost: function(event){<br
/> this.ghost.setStyles({&#039;left&#039;: event.page.x-this.offsetX,<br
/> &#039;top&#039;: event.page.y-this.offsetY<br
/> });<br
/> event.stop();<br
/> },</p><p> move: function(event){<br
/> var cor = this.active.getCoordinates();<br
/> if(cor.left &lt; event.page.x &amp;&amp; event.page.x  cor.top &amp;&amp; event.page.y  list.getCoordinates().left) clist = list;<br
/> }, this);</p><p> if(clist == this.active._p) {<br
/> var now = event.page.y;<br
/> this.previous = this.previous || now;<br
/> var up = ((this.previous &#8211; now) &gt; 0);<br
/> var prev = this.active.getPrevious();<br
/> var next = this.active.getNext();<br
/> if (prev &amp;&amp; up &amp;&amp; now  next._h.getCoordinates().top) this.active.injectAfter(next);<br
/> this.previous = now;<br
/> }else{<br
/> var now = event.page.y;</p><p> //Get correct position<br
/> var els = clist.getChildren();<br
/> if(els.length) {<br
/> var cel = els[0];<br
/> els.each(function(el, idx){<br
/> if (now &gt; el._h.getCoordinates().bottom)<br
/> {<br
/> if(idx &lt; els.length &#8211; 1) cel = els[idx+1];<br
/> else cel = null;<br
/> }<br
/> },this);</p><p> if(cel) this.active.injectBefore(cel);<br
/> else this.active.inject(clist);<br
/> } else {<br
/> this.active.inject(clist);<br
/> }<br
/> this.active._p = clist;<br
/> this.previous = now;<br
/> }</p><p> },</p><p> serialize: function(converter){<br
/> return this.list.getChildren().map(converter || function(el){<br
/> return this.elements.indexOf(el);<br
/> }, this);<br
/> },</p><p> end: function(){<br
/> this.previous = null;<br
/> document.removeListener(&#039;mousemove&#039;, this.bound.move);<br
/> document.removeListener(&#039;mouseup&#039;, this.bound.end);<br
/> if (this.options.ghost){<br
/> document.removeListener(&#039;mousemove&#039;, this.bound.moveGhost);<br
/> this.fireEvent(&#039;onDragComplete&#039;, [this.active, this.ghost]);<br
/> }<br
/> this.fireEvent(&#039;onComplete&#039;, this.active);<br
/> },</p><p> saveCookies: function() {<br
/> if (Cookie.get(&quot;ja-ordercolumn&quot;) == &#039;-&#039;) {<br
/> Cookie.set(&quot;ja-ordercolumn&quot;, &#039;&#039;,{path:&#039;/&#039;});<br
/> return;<br
/> }<br
/> c = &#039;&#039;;<br
/> this.lists.each(function(list){<br
/> var elements = list.getChildren();<br
/> if (!elements){<br
/> return;<br
/> }<br
/> elements.each(function(el,i){<br
/> c += el._p.id + &quot;_&quot; + el._h.innerHTML.trim().substr(0,20) + &quot;_&quot; + i + &quot;_&quot; + el._h.className+&quot;,&quot;;<br
/> },this);<br
/> },this);<br
/> if (this.hc) {<br
/> this.hc.each(function(value, k){<br
/> if (!c.test (&#039;_&#039; + value[1] + &#039;_&#039;)) {<br
/> c += value[0] + &quot;_&quot; + value[1] + &quot;_&quot; + value[2] + &quot;_&quot; + value[3]+&quot;,&quot;;<br
/> }<br
/> },this);<br
/> }<br
/> c = c.substr(0, (c.length-1));<br
/> Cookie.set(&quot;ja-ordercolumn&quot;, c, {duration: 365,path:&#039;/&#039;});<br
/> }<br
/> });</p><p>document.write(&#039;.ja-movable-container{visibility: hidden;}&#8217;);<br
/> window.addEvent(&#8216;load&#8217;, function(){<br
/> new JADDModules($$(&#8220;.ja-movable-container&#8221;), {src_collap_1:src_collap_1, src_collap_2:src_collap_2});<br
/> });</p><p>JADDModules.implement(new Events, new Options);</p><p>JAResizer = new Class({<br
/> initialize: function(els, options){<br
/> this.options = Object.extend({<br
/> min: 100,<br
/> max: 0<br
/> }, options || {});<br
/> $$(els).each(function(el){<br
/> el.onmouseover = function(){<br
/> this.addClass(&#8216;ja-colresizehover&#8217;);<br
/> };</p><p> resizemouseout = function(){<br
/> //console.log(&#8216;call mouse out event for &#8216; + this);<br
/> this.removeClass(&#8216;ja-colresizehover&#8217;);<br
/> }<br
/> el.onmouseout = resizemouseout;</p><p> var prev = el.getPrevious();<br
/> var next = el.getNext();<br
/> prev.makeResizableNew ({handle: el, modifiers:{y:false}, limit:{width:[100]}});<br
/> next.makeResizableNew ({handle: el, modifiers:{y:false}, dir: -1, limit:{width:[100]}});<br
/> var eld = el.makeDraggable({modifiers:{y:false}});</p><p> eld.addEvent(&#8216;onStart&#8217;, function (el) {<br
/> //console.log(&#8216;Remove mouse out for &#8216; + eld.element);<br
/> el.onmouseout = null;<br
/> this._next = el.getNext();<br
/> this._prev = el.getPrevious();<br
/> this._w = this._prev.getStyle(&#8216;width&#8217;).toFloat() + this._next.getStyle(&#8216;width&#8217;).toFloat();<br
/> });</p><p> eld.addEvent(&#8216;onComplete&#8217;, function (el) {<br
/> el.onmouseout = resizemouseout;</p><p> var w1 = this._prev.offsetWidth;<br
/> var w2 = this._next.offsetWidth;<br
/> var w1p = w1/(w1+w2)*this._w;<br
/> var w2p = w2/(w1+w2)*this._w;<br
/> var elwp = el.offsetLeft * this._w / (w1+w2);<br
/> this._prev.setStyle(&#8216;width&#8217;, w1p + &#8216;%&#8217;);<br
/> this._next.setStyle(&#8216;width&#8217;, w2p + &#8216;%&#8217;);<br
/> el.setStyle (&#8216;left&#8217;, elwp + &#8216;%&#8217;);</p><p> el = el.getCoordinates(this.options.overflown);<br
/> var now = this.mouse.now;<br
/> if (!(now.x &gt; el.left &amp;&amp; now.x &lt; el.right &amp;&amp; now.y  el.top)) resizemouseout.call(this.element);</p><p> });<br
/> }.bind( this));<br
/> }<br
/> });</p><p>Drag.Resize = Drag.Base.extend({</p><p> options: {<br
/> dir: 1<br
/> },</p><p> initialize: function(el, options){<br
/> this.setOptions(options);<br
/> this.parent(el);<br
/> },</p><p> start: function(event){<br
/> this.fireEvent(&#8216;onBeforeStart&#8217;, this.element);<br
/> this.mouse.start = event.page;<br
/> var limit = this.options.limit;<br
/> this.limit = {&#8216;x&#8217;: [], &#8216;y&#8217;: []};<br
/> for (var z in this.options.modifiers){<br
/> if (!this.options.modifiers[z]) continue;<br
/> this.value.now[z] = this.element.getCoordinates()[this.options.modifiers[z]].toInt();<br
/> this.mouse.pos[z] = event.page[z] &#8211; this.value.now[z]*this.options.dir;<br
/> if (limit &amp;&amp; limit[z]){<br
/> for (var i = 0; i  this.limit[z][1])){<br
/> this.value.now[z] = this.limit[z][1];<br
/> this.out = true;<br
/> } else if ($chk(this.limit[z][0]) &amp;&amp; (this.value.now[z] &lt; this.limit[z][0])){<br
/> this.value.now[z] = this.limit[z][0];<br
/> this.out = true;<br
/> }<br
/> }<br
/> if (this.options.grid[z]) this.value.now[z] -= (this.value.now[z] % this.options.grid[z]);<br
/> this.element.setStyle(this.options.modifiers[z], this.value.now[z] + this.options.unit);<br
/> }<br
/> this.fireEvent(&#039;onDrag&#039;, this.element);<br
/> event.stop();<br
/> }</p><p>});</p><p>/*<br
/> Class: Element<br
/> Custom class to allow all of its methods to be used with any DOM element via the dollar function .<br
/> */</p><p>Element.extend({</p><p> /*<br
/> Property: makeDraggable<br
/> Makes an element draggable with the supplied options.</p><p> Arguments:<br
/> options &#8211; see  and  for acceptable options.<br
/> */</p><p> makeResizableNew: function(options){<br
/> return new Drag.Resize(this, $merge({modifiers: {x: &#8216;width&#8217;, y: &#8216;height&#8217;}}, options));<br
/> }</p><p>});</p><p>This works in mootools 1.12, but not work in 1.2.x, please help me</p> ]]></content:encoded> </item> <item><title>By: veyron</title><link>http://davidwalsh.name/mootools-drag-drop-lock#comment-8068</link> <dc:creator>veyron</dc:creator> <pubDate>Thu, 05 Mar 2009 20:27:39 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=249#comment-8068</guid> <description>Hi David! How can I get the position of the dragable object? I need them to put into a database... Can you help me?
By the way: your site is perfect =)Thanks :D</description> <content:encoded><![CDATA[<p>Hi David! How can I get the position of the dragable object? I need them to put into a database&#8230; Can you help me?<br
/> By the way: your site is perfect =)</p><p>Thanks :D</p> ]]></content:encoded> </item> <item><title>By: mike</title><link>http://davidwalsh.name/mootools-drag-drop-lock#comment-8007</link> <dc:creator>mike</dc:creator> <pubDate>Tue, 03 Mar 2009 11:36:43 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=249#comment-8007</guid> <description>it&#039;s all good thxt i will play arround with it!</description> <content:encoded><![CDATA[<p>it&#8217;s all good thxt i will play arround with it!</p> ]]></content:encoded> </item> <item><title>By: rpflo</title><link>http://davidwalsh.name/mootools-drag-drop-lock#comment-8004</link> <dc:creator>rpflo</dc:creator> <pubDate>Tue, 03 Mar 2009 02:54:41 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=249#comment-8004</guid> <description>@mikeSounds like you need to go through the &lt;a href=&quot;http://www.mootorial.com/wiki/&quot; rel=&quot;nofollow&quot;&gt;mootorial&lt;/a&gt;, or at least get a bit more familiar with mootools.I said to put in the onDrop funciton, scroll up to David&#039;s code and you&#039;ll see an &quot;onDrop&quot; function.  That&#039;s where :)el = the element being draggeddroppable = the element receivingYou&#039;d probably need those to give the database anything worthwhile.I knew nothing about javascript less than a year ago but with mootools I&#039;m able to do all sorts of crap I once thought impossible.  It&#039;s just too easy to pick up.</description> <content:encoded><![CDATA[<p>@mike</p><p>Sounds like you need to go through the <a
href="http://www.mootorial.com/wiki/" rel="nofollow">mootorial</a>, or at least get a bit more familiar with mootools.</p><p>I said to put in the onDrop funciton, scroll up to David&#8217;s code and you&#8217;ll see an &#8220;onDrop&#8221; function.  That&#8217;s where :)</p><p>el = the element being dragged</p><p>droppable = the element receiving</p><p>You&#8217;d probably need those to give the database anything worthwhile.</p><p>I knew nothing about javascript less than a year ago but with mootools I&#8217;m able to do all sorts of crap I once thought impossible.  It&#8217;s just too easy to pick up.</p> ]]></content:encoded> </item> <item><title>By: mike</title><link>http://davidwalsh.name/mootools-drag-drop-lock#comment-7995</link> <dc:creator>mike</dc:creator> <pubDate>Mon, 02 Mar 2009 15:00:51 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=249#comment-7995</guid> <description>i still dont see were i would put this code?and why  function(el,droppable)</description> <content:encoded><![CDATA[<p>i still dont see were i would put this code?and why  function(el,droppable)</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.006 seconds using disk: basic
Object Caching 802/802 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-23 09:14:23 -->
