1 /*********************************************************************************
2 * SugarCRM Community Edition is a customer relationship management program developed by
3 * SugarCRM, Inc. Copyright (C) 2004-2011 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 ********************************************************************************/
37 Studio2.ListDD = function(el, sGroup, fromOnly) {
38 if (typeof el == 'number') {
41 if (typeof el == 'string')
42 el = document.getElementById(el);
44 var Dom = YAHOO.util.Dom;
45 Studio2.ListDD.superclass.constructor.call(this, el, sGroup);
46 this.addInvalidHandleType("input");
47 this.addInvalidHandleType("a");
48 var dEl = this.getDragEl()
49 Dom.setStyle(dEl, "borderColor", "#FF0000");
50 Dom.setStyle(dEl, "backgroundColor", "#e5e5e5");
51 Dom.setStyle(dEl, "opacity", 0.76);
52 Dom.setStyle(dEl, "filter", "alpha(opacity=76)");
53 this.fromOnly = fromOnly;
57 YAHOO.extend(Studio2.ListDD, YAHOO.util.DDProxy, {
58 copyStyles : {'opacity':"", 'border':"", 'height':"", 'filter':"", 'zoom':""},
59 startDrag: function(x, y){
60 //We need to make sure no inline editors are in use, as drag.drop can break them
61 if (typeof (SimpleList) != "undefined") {
62 SimpleList.endCurrentDropDownEdit();
65 var Dom = YAHOO.util.Dom;
66 var dragEl = this.getDragEl();
67 var clickEl = this.getEl();
69 this.parentID = clickEl.parentNode.id;
70 this.clickContent = clickEl.innerHTML;
71 dragEl.innerHTML = clickEl.innerHTML;
73 Dom.addClass(dragEl, clickEl.className);
74 Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
75 Dom.setStyle(dragEl, "height", Dom.getStyle(clickEl, "height"));
76 Dom.setStyle(dragEl, "border", "1px solid #aaa");
78 // save the style of the object
79 if (this.clickStyle == null) {
81 for (var s in this.copyStyles) {
82 this.clickStyle[s] = clickEl.style[s];
84 if (typeof(this.clickStyle['border']) == 'undefined' || this.clickStyle['border'] == "")
85 this.clickStyle['border'] = "1px solid";
88 Dom.setStyle(clickEl, "opacity", 0.5);
89 Dom.setStyle(clickEl, "filter", "alpha(opacity=10)");
90 Dom.setStyle(clickEl, "border", '2px dashed #cccccc');
93 updateTabs: function(){
94 studiotabs.moduleTabs = [];
95 for (j = 0; j < studiotabs.slotCount; j++) {
97 var ul = document.getElementById('ul' + j);
98 studiotabs.moduleTabs[j] = [];
99 items = ul.getElementsByTagName("li");
100 for (i = 0; i < items.length; i++) {
101 if (items.length == 1) {
102 items[i].innerHTML = SUGAR.language.get('ModuleBuilder', 'LBL_DROP_HERE');
104 else if (items[i].innerHTML == SUGAR.language.get('ModuleBuilder', 'LBL_DROP_HERE')) {
105 items[i].innerHTML = '';
107 studiotabs.moduleTabs[ul.id.substr(2, ul.id.length)][studiotabs.subtabModules[items[i].id]] = true;
112 endDrag: function(e){
113 ModuleBuilder.state.isDirty=true;
114 var clickEl = this.getEl();
115 var clickExEl = new YAHOO.util.Element(clickEl);
116 dragEl = this.getDragEl();
117 dragEl.innerHTML = "";
118 clickEl.innerHTML = this.clickContent;
120 var p = clickEl.parentNode;
121 if (p.id == 'trash') {
122 p.removeChild(clickEl);
123 this.lastNode = false;
128 for(var style in this.clickStyle) {
129 if (typeof(this.clickStyle[style]) != 'undefined')
130 clickExEl.setStyle(style, this.clickStyle[style]);
132 clickExEl.setStyle(style, '');
135 this.clickStyle = null;
138 this.lastNode.id = 'addLS' + addListStudioCount;
139 studiotabs.subtabModules[this.lastNode.id] = this.lastNode.module;
140 yahooSlots[this.lastNode.id] = new Studio2.ListDD(this.lastNode.id, 'subTabs', false);
141 addListStudioCount++;
142 this.lastNode.style.opacity = 1;
143 this.lastNode.style.filter = "alpha(opacity=100)";
145 this.lastNode = false;
148 dragEl.innerHTML = "";
151 onDragOver: function(e, id){
154 this.lastNode.parentNode.removeChild(this.lastNode);
155 this.lastNode = false;
157 if (id.substr(0, 7) == 'modSlot') {
160 el = document.getElementById(id);
161 dragEl = this.getDragEl();
163 var mid = YAHOO.util.Dom.getY(el) + (el.clientHeight / 2);
164 var el2 = this.getEl();
165 var p = el.parentNode;
166 if ((this.fromOnly || (el.id != 'trashcan' && el2.parentNode.id != p.id && el2.parentNode.id == this.parentID))) {
167 if (typeof(studiotabs.moduleTabs[p.id.substr(2, p.id.length)][studiotabs.subtabModules[el2.id]]) != 'undefined')
171 if (this.fromOnly && el.id != 'trashcan') {
172 el2 = el2.cloneNode(true);
173 el2.module = studiotabs.subtabModules[el2.id];
174 el2.id = 'addListStudio' + addListStudioCount;
176 this.lastNode.clickContent = el2.clickContent;
177 this.lastNode.clickBorder = el2.clickBorder;
178 this.lastNode.clickHeight = el2.clickHeight
181 if (YAHOO.util.Dom.getY(dragEl) < mid) { // insert on top triggering item
182 p.insertBefore(el2, el);
184 else { // insert below triggered item
185 p.insertBefore(el2, el.nextSibling);