]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/modules/Studio/ygDDListStudio.js
Release 6.5.0
[Github/sugarcrm.git] / jssource / src_files / modules / Studio / ygDDListStudio.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
36
37
38
39 /* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
40
41 /**
42  * @class a YAHOO.util.DDProxy implementation. During the drag over event, the
43  * dragged element is inserted before the dragged-over element.
44  *
45  * @extends YAHOO.util.DDProxy
46  * @constructor
47  * @param {String} id the id of the linked element
48  * @param {String} sGroup the group of related DragDrop objects
49  */
50 var addListStudioCount = 0;
51 var moduleTabs = [];
52
53
54 function ygDDListStudio(id, sGroup, fromOnly) {
55
56         if (id) {
57         
58                 if(id == 'trashcan' || id.indexOf('noselect') ==0){
59                         this.initTarget(id, sGroup);
60                 }else{
61                         this.init(id, sGroup);
62                 }
63                 this.initFrame();
64                 this.fromOnly = fromOnly;
65         }
66
67         var s = this.getDragEl().style;
68         s.borderColor = "transparent";
69         s.backgroundColor = "#f6f5e5";
70         s.opacity = 0.76;
71         s.filter = "alpha(opacity=76)";
72 }
73
74
75 ygDDListStudio.prototype = new YAHOO.util.DDProxy();
76 ygDDListStudio.prototype.clickContent = '';
77 ygDDListStudio.prototype.clickBorder = '';
78 ygDDListStudio.prototype.clickHeight = '';
79 ygDDListStudio.prototype.lastNode = false;
80 ygDDListStudio.prototype.startDrag
81 ygDDListStudio.prototype.startDrag = function(x, y) {
82
83         var dragEl = this.getDragEl();
84         var clickEl = this.getEl();
85  
86   this.parentID = clickEl.parentNode.id;
87         dragEl.innerHTML = clickEl.innerHTML;
88         dragElObjects = dragEl.getElementsByTagName('object');
89         
90         dragEl.className = clickEl.className;
91         dragEl.style.color = clickEl.style.color;
92         dragEl.style.border = "1px solid #aaa";
93
94         // save the style of the object 
95         this.clickContent = clickEl.innerHTML;
96         this.clickBorder = clickEl.style.border;
97         this.clickHeight = clickEl.style.height;
98         
99         clickElRegion = YAHOO.util.Dom.getRegion(clickEl);
100         clickEl.style.height = (clickElRegion.bottom - clickElRegion.top) + 'px';
101         clickEl.style.opacity = .5;
102         clickEl.style.filter = "alpha(opacity=10)";
103         clickEl.style.border = '2px dashed #cccccc';
104 };
105 ygDDListStudio.prototype.updateTabs = function(){
106                 moduleTabs = [];
107                 for(j = 0; j < slotCount; j++){
108                         
109                         var ul = document.getElementById('ul' + j);
110                         moduleTabs[j] = [];
111                         items = ul.getElementsByTagName("li");
112                         for(i = 0; i < items.length; i++) {
113                                 if(items.length == 1){
114                                         items[i].innerHTML = SUGAR.language.get('app_strings', 'LBL_DROP_HERE'); 
115                                         
116                                 }else{
117                                         if(items[i].innerHTML == SUGAR.language.get('app_strings', 'LBL_DROP_HERE')){
118                                                 items[i].innerHTML='';
119                                         } 
120                                 }
121
122                                 moduleTabs[ul.id.substr(2, ul.id.length)][subtabModules[items[i].id]] = true;
123                         }
124                         
125                 }
126         
127 };
128 ygDDListStudio.prototype.endDrag = function(e) {
129         
130         var clickEl = this.getEl();
131         clickEl.innerHTML = this.clickContent
132         var p = clickEl.parentNode;
133         if(p.id == 'trash'){
134                 p.removeChild(clickEl);
135                 this.lastNode = false;
136                 this.updateTabs();
137                 return;
138         }
139         if(this.clickHeight) {
140             clickEl.style.height = this.clickHeight;
141                         if(this.lastNode)this.lastNode.style.height=this.clickHeight;
142         }
143         else{ 
144                 clickEl.style.height = '';
145                 if(this.lastNode)this.lastNode.style.height='';
146                 }
147         
148         if(this.clickBorder){ 
149             clickEl.style.border = this.clickBorder;
150                         if(this.lastNode)this.lastNode.style.border=this.clickBorder;
151         }
152         else {
153                 clickEl.style.border = '';
154                         if(this.lastNode)this.lastNode.style.border='';
155                 }
156                 clickEl.style.opacity = 1;
157                                 clickEl.style.filter = "alpha(opacity=100)";
158                 if(this.lastNode){
159                         this.lastNode.id = 'addLS' + addListStudioCount;
160                         subtabModules[this.lastNode.id] = this.lastNode.module;
161                         yahooSlots[this.lastNode.id] = new ygDDListStudio(this.lastNode.id, 'subTabs', false);
162                         addListStudioCount++;
163                                 this.lastNode.style.opacity = 1;
164                                 this.lastNode.style.filter = "alpha(opacity=100)";
165                 }
166         this.lastNode = false;
167         this.updateTabs();
168 };
169
170 ygDDListStudio.prototype.onDrag = function(e, id) {
171                 
172 };
173
174 ygDDListStudio.prototype.onDragOver = function(e, id) {
175         // this.logger.debug(this.id.toString() + " onDragOver " + id);
176         var el;
177                  if(this.lastNode){
178                         this.lastNode.parentNode.removeChild(this.lastNode);
179                         this.lastNode = false;
180                 }
181      if(id.substr(0, 7) == 'modSlot'){
182         return;
183      }   
184     if ("string" == typeof id) {
185         el = YAHOO.util.DDM.getElement(id);
186     } else { 
187         el = YAHOO.util.DDM.getBestMatch(id).getEl();
188     }
189     
190         dragEl = this.getDragEl();
191         elRegion = YAHOO.util.Dom.getRegion(el);
192     
193
194         var mid = YAHOO.util.DDM.getPosY(el) + (Math.floor((elRegion.bottom - elRegion.top) / 2));
195         var el2 = this.getEl();
196         var p = el.parentNode;
197  if( (this.fromOnly ||  ( el.id != 'trashcan' && el2.parentNode.id != p.id && el2.parentNode.id == this.parentID)) ){
198         if(typeof(moduleTabs[p.id.substr(2,p.id.length)][subtabModules[el2.id]]) != 'undefined')return;
199                 
200         }
201         
202  if(this.fromOnly && el.id != 'trashcan'){
203         el2 = el2.cloneNode(true);
204         el2.module = subtabModules[el2.id];
205         el2.id = 'addListStudio' + addListStudioCount;
206         this.lastNode = el2;
207         this.lastNode.clickContent = el2.clickContent;
208         this.lastNode.clickBorder = el2.clickBorder;
209         this.lastNode.clickHeight = el2.clickHeight
210
211         
212   }
213         if (YAHOO.util.DDM.getPosY(dragEl) < mid ) { // insert on top triggering item
214                 p.insertBefore(el2, el);
215         }
216         if (YAHOO.util.DDM.getPosY(dragEl) >= mid ) { // insert below triggered item
217                 p.insertBefore(el2, el.nextSibling);
218         }
219         
220         
221 };
222
223 ygDDListStudio.prototype.onDragEnter = function(e, id) {
224         
225 };
226
227 ygDDListStudio.prototype.onDragOut = function(e, id) {
228  
229 }
230
231 /////////////////////////////////////////////////////////////////////////////
232
233 function ygDDListStudioBoundary(id, sGroup) {
234         if (id) {
235                 this.init(id, sGroup);
236                 this.isBoundary = true;
237         }
238 }
239
240 ygDDListStudioBoundary.prototype = new YAHOO.util.DDTarget();