]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Studio/studiodd.js
Release 6.5.0
[Github/sugarcrm.git] / modules / Studio / studiodd.js
1 /*********************************************************************************
2  * SugarCRM Community Edition is a customer relationship management program developed by
3  * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Affero General Public License version 3 as published by the
7  * Free Software Foundation with the addition of the following permission added
8  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
9  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
10  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU Affero General Public License along with
18  * this program; if not, see http://www.gnu.org/licenses or write to the Free
19  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  * 02110-1301 USA.
21  *
22  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
23  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
24  *
25  * The interactive user interfaces in modified source and object code versions
26  * of this program must display Appropriate Legal Notices, as required under
27  * Section 5 of the GNU Affero General Public License version 3.
28  *
29  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
30  * these Appropriate Legal Notices must retain the display of the "Powered by
31  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
32  * technical reasons, the Appropriate Legal Notices must display the words
33  * "Powered by SugarCRM".
34  ********************************************************************************/
35 function ygDDSlot(id,sGroup){if(id){this.init(id,sGroup);this.initFrame();}
36 var s=this.getDragEl().style;s.borderColor="transparent";s.backgroundColor="#f6f5e5";s.opacity=0.76;s.filter="alpha(opacity=76)";this.resizeFrame=true;if(id=='s_field_delete'){this.isValidHandle=false;}}
37 ygDDSlot.prototype=new YAHOO.util.DDProxy();ygDDSlot.prototype.handleDelete=function(cur,curb){var parentID=(typeof(cur.parentID)=='undefined')?cur.id.substr(4,cur.id.length):cur.parentID;if(parentID.indexOf('field')==0){return false;}
38 var myfieldcount=field_count_MSI;addNewField('dyn_field_'+field_count_MSI,'delete',' ',' ','deleted',0,'studio_fields')
39 yahooSlots["dyn_field_"+myfieldcount]=new ygDDSlot("dyn_field_"+myfieldcount,"studio");ygDDSlot.prototype.handleSwap(cur,curb,document.getElementById("dyn_field_"+myfieldcount),document.getElementById("dyn_field_"+myfieldcount+'b'),true);}
40 ygDDSlot.prototype.undo=function(transaction){ygDDSlot.prototype.handleSwap(document.getElementById(transaction['el']),document.getElementById(transaction['elb']),document.getElementById(transaction['cur']),document.getElementById(transaction['curb']),false);}
41 ygDDSlot.prototype.redo=function(transaction){ygDDSlot.prototype.handleSwap(document.getElementById(transaction['el']),document.getElementById(transaction['elb']),document.getElementById(transaction['cur']),document.getElementById(transaction['curb']),false);}
42 ygDDSlot.prototype.handleSwap=function(cur,curb,el,elb,record){if(record){if(curb){jstransaction.record('studioSwap',{'cur':cur.id,'curb':curb.id,'el':el.id,'elb':elb.id});}else{jstransaction.record('studioSwap',{'cur':cur.id,'curb':null,'el':el.id,'elb':null});}}
43 var parentID1=(typeof(el.parentID)=='undefined')?el.id.substr(4,el.id.length):el.parentID;var parentID2=(typeof(cur.parentID)=='undefined')?cur.id.substr(4,cur.id.length):cur.parentID;var slot1=YAHOO.util.DDM.getElement("slot_"+parentID1);var slot2=YAHOO.util.DDM.getElement("slot_"+parentID2);var temp=slot1.value;slot1.value=slot2.value;slot2.value=temp;YAHOO.util.DDM.swapNode(cur,el);if(curb){YAHOO.util.DDM.swapNode(curb,elb);}
44 cur.parentID=parentID1;el.parentID=parentID2;if(parentID1.indexOf('field')==0){if(curb)curb.style.display='none';setMouseOverForField(cur,true);}else{if(curb)curb.style.display='inline';setMouseOverForField(cur,false);}
45 if(parentID2.indexOf('field')==0){if(elb)elb.style.display='none';setMouseOverForField(el,true);}else{if(elb)elb.style.display='inline';setMouseOverForField(el,false);}}
46 ygDDSlot.prototype.onDragDrop=function(e,id){var cur=this.getEl();var curb;if("string"==typeof id){curb=YAHOO.util.DDM.getElement(cur.id+"b");}else{curb=YAHOO.util.DDM.getBestMatch(cur.id+"b").getEl();}
47 if(id=='s_field_delete'){id=ygDDSlot.prototype.handleDelete(cur,curb);if(!id)return false;}
48 var el;if("string"==typeof id){el=YAHOO.util.DDM.getElement(id);}else{el=YAHOO.util.DDM.getBestMatch(id).getEl();}
49 id2=el.id+"b";if("string"==typeof id){elb=YAHOO.util.DDM.getElement(id2);}else{elb=YAHOO.util.DDM.getBestMatch(id2).getEl();}
50 ygDDSlot.prototype.handleSwap(cur,curb,el,elb,true)
51 var dragEl=this.getDragEl();dragEl.innerHTML='';};ygDDSlot.prototype.startDrag=function(x,y){var dragEl=this.getDragEl();var clickEl=this.getEl();dragEl.innerHTML=clickEl.innerHTML;dragEl.className=clickEl.className;dragEl.style.color=clickEl.style.color;dragEl.style.border="2px solid #aaa";this.clickContent=clickEl.innerHTML;this.clickBorder=clickEl.style.border;this.clickHeight=clickEl.style.height;clickElRegion=YAHOO.util.Dom.getRegion(clickEl);dragEl.style.height=clickEl.style.height;dragEl.style.width=(clickElRegion.right-clickElRegion.left)+'px';clickEl.style.height=(clickElRegion.bottom-clickElRegion.top)+'px';clickEl.style.border='2px dashed #cccccc';clickEl.style.opacity=.5;clickEl.style.filter="alpha(opacity=10)";};ygDDSlot.prototype.endDrag=function(e){var clickEl=this.getEl();if(this.clickHeight)
52 clickEl.style.height=this.clickHeight;else
53 clickEl.style.height='';if(this.clickBorder)
54 clickEl.style.border=this.clickBorder;else
55 clickEl.style.border='';clickEl.style.opacity=1;clickEl.style.filter="alpha(opacity=100)";};jstransaction.register('studioSwap',ygDDSlot.prototype.undo,ygDDSlot.prototype.redo);