1 /*********************************************************************************
2 * SugarCRM Community Edition is a customer relationship management program developed by
3 * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
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.
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
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
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.
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.
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 ********************************************************************************/
39 /* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
42 * @class a YAHOO.util.DDProxy implementation. During the drag over event, the
43 * dragged element is inserted before the dragged-over element.
45 * @extends YAHOO.util.DDProxy
47 * @param {String} id the id of the linked element
48 * @param {String} sGroup the group of related DragDrop objects
50 var addListStudioCount = 0;
54 function ygDDListStudio(id, sGroup, fromOnly) {
58 if(id == 'trashcan' || id.indexOf('noselect') ==0){
59 this.initTarget(id, sGroup);
61 this.init(id, sGroup);
64 this.fromOnly = fromOnly;
67 var s = this.getDragEl().style;
68 s.borderColor = "transparent";
69 s.backgroundColor = "#f6f5e5";
71 s.filter = "alpha(opacity=76)";
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) {
83 var dragEl = this.getDragEl();
84 var clickEl = this.getEl();
86 this.parentID = clickEl.parentNode.id;
87 dragEl.innerHTML = clickEl.innerHTML;
88 dragElObjects = dragEl.getElementsByTagName('object');
90 dragEl.className = clickEl.className;
91 dragEl.style.color = clickEl.style.color;
92 dragEl.style.border = "1px solid #aaa";
94 // save the style of the object
95 this.clickContent = clickEl.innerHTML;
96 this.clickBorder = clickEl.style.border;
97 this.clickHeight = clickEl.style.height;
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';
105 ygDDListStudio.prototype.updateTabs = function(){
107 for(j = 0; j < slotCount; j++){
109 var ul = document.getElementById('ul' + 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');
117 if(items[i].innerHTML == SUGAR.language.get('app_strings', 'LBL_DROP_HERE')){
118 items[i].innerHTML='';
122 moduleTabs[ul.id.substr(2, ul.id.length)][subtabModules[items[i].id]] = true;
128 ygDDListStudio.prototype.endDrag = function(e) {
130 var clickEl = this.getEl();
131 clickEl.innerHTML = this.clickContent
132 var p = clickEl.parentNode;
134 p.removeChild(clickEl);
135 this.lastNode = false;
139 if(this.clickHeight) {
140 clickEl.style.height = this.clickHeight;
141 if(this.lastNode)this.lastNode.style.height=this.clickHeight;
144 clickEl.style.height = '';
145 if(this.lastNode)this.lastNode.style.height='';
148 if(this.clickBorder){
149 clickEl.style.border = this.clickBorder;
150 if(this.lastNode)this.lastNode.style.border=this.clickBorder;
153 clickEl.style.border = '';
154 if(this.lastNode)this.lastNode.style.border='';
156 clickEl.style.opacity = 1;
157 clickEl.style.filter = "alpha(opacity=100)";
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)";
166 this.lastNode = false;
170 ygDDListStudio.prototype.onDrag = function(e, id) {
174 ygDDListStudio.prototype.onDragOver = function(e, id) {
175 // this.logger.debug(this.id.toString() + " onDragOver " + id);
178 this.lastNode.parentNode.removeChild(this.lastNode);
179 this.lastNode = false;
181 if(id.substr(0, 7) == 'modSlot'){
184 if ("string" == typeof id) {
185 el = YAHOO.util.DDM.getElement(id);
187 el = YAHOO.util.DDM.getBestMatch(id).getEl();
190 dragEl = this.getDragEl();
191 elRegion = YAHOO.util.Dom.getRegion(el);
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;
202 if(this.fromOnly && el.id != 'trashcan'){
203 el2 = el2.cloneNode(true);
204 el2.module = subtabModules[el2.id];
205 el2.id = 'addListStudio' + addListStudioCount;
207 this.lastNode.clickContent = el2.clickContent;
208 this.lastNode.clickBorder = el2.clickBorder;
209 this.lastNode.clickHeight = el2.clickHeight
213 if (YAHOO.util.DDM.getPosY(dragEl) < mid ) { // insert on top triggering item
214 p.insertBefore(el2, el);
216 if (YAHOO.util.DDM.getPosY(dragEl) >= mid ) { // insert below triggered item
217 p.insertBefore(el2, el.nextSibling);
223 ygDDListStudio.prototype.onDragEnter = function(e, id) {
227 ygDDListStudio.prototype.onDragOut = function(e, id) {
231 /////////////////////////////////////////////////////////////////////////////
233 function ygDDListStudioBoundary(id, sGroup) {
235 this.init(id, sGroup);
236 this.isBoundary = true;
240 ygDDListStudioBoundary.prototype = new YAHOO.util.DDTarget();