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 ********************************************************************************/
37 max_default_columns = 6;
39 Studio2.ListDD = function(el, sGroup, fromOnly) {
40 if (typeof el == 'number') {
43 if (typeof el == 'string')
44 el = document.getElementById(el);
46 var Dom = YAHOO.util.Dom;
47 Studio2.ListDD.superclass.constructor.call(this, el, sGroup);
48 this.addInvalidHandleType("input");
49 this.addInvalidHandleType("a");
50 var dEl = this.getDragEl()
51 Dom.setStyle(dEl, "borderColor", "#FF0000");
52 Dom.setStyle(dEl, "backgroundColor", "#e5e5e5");
53 Dom.setStyle(dEl, "opacity", 0.76);
54 Dom.setStyle(dEl, "filter", "alpha(opacity=76)");
55 this.fromOnly = fromOnly;
59 YAHOO.extend(Studio2.ListDD, YAHOO.util.DDProxy, {
60 copyStyles : {'opacity':"", 'border':"", 'height':"", 'filter':"", 'zoom':""},
61 startDrag: function(x, y){
62 //We need to make sure no inline editors are in use, as drag.drop can break them
63 if (typeof (SimpleList) != "undefined") {
64 SimpleList.endCurrentDropDownEdit();
67 var Dom = YAHOO.util.Dom;
68 var dragEl = this.getDragEl();
69 var clickEl = this.getEl();
71 this.parentID = clickEl.parentNode.id;
72 this.clickContent = clickEl.innerHTML;
73 dragEl.innerHTML = clickEl.innerHTML;
75 Dom.addClass(dragEl, clickEl.className);
76 Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
77 Dom.setStyle(dragEl, "height", Dom.getStyle(clickEl, "height"));
78 Dom.setStyle(dragEl, "border", "1px solid #aaa");
80 // save the style of the object
81 if (this.clickStyle == null) {
83 for (var s in this.copyStyles) {
84 this.clickStyle[s] = clickEl.style[s];
86 if (typeof(this.clickStyle['border']) == 'undefined' || this.clickStyle['border'] == "")
87 this.clickStyle['border'] = "1px solid";
90 Dom.setStyle(clickEl, "opacity", 0.5);
91 Dom.setStyle(clickEl, "filter", "alpha(opacity=10)");
92 Dom.setStyle(clickEl, "border", '2px dashed #cccccc');
93 Studio2.setScrollObj(this);
96 updateTabs: function(){
97 studiotabs.moduleTabs = [];
98 for (j = 0; j < studiotabs.slotCount; j++) {
100 var ul = document.getElementById('ul' + j);
101 studiotabs.moduleTabs[j] = [];
102 items = ul.getElementsByTagName("li");
103 for (i = 0; i < items.length; i++) {
104 if (items.length == 1) {
105 items[i].innerHTML = SUGAR.language.get('ModuleBuilder', 'LBL_DROP_HERE');
107 else if (items[i].innerHTML == SUGAR.language.get('ModuleBuilder', 'LBL_DROP_HERE')) {
108 items[i].innerHTML = '';
110 studiotabs.moduleTabs[ul.id.substr(2, ul.id.length)][studiotabs.subtabModules[items[i].id]] = true;
115 endDrag: function(e){
116 Studio2.clearScrollObj();
117 ModuleBuilder.state.isDirty=true;
118 var clickEl = this.getEl();
119 var clickExEl = new YAHOO.util.Element(clickEl);
120 dragEl = this.getDragEl();
121 dragEl.innerHTML = "";
122 clickEl.innerHTML = this.clickContent;
124 var p = clickEl.parentNode;
125 if (p.id == 'trash') {
126 p.removeChild(clickEl);
127 this.lastNode = false;
132 for(var style in this.clickStyle) {
133 if (typeof(this.clickStyle[style]) != 'undefined')
134 clickExEl.setStyle(style, this.clickStyle[style]);
136 clickExEl.setStyle(style, '');
139 this.clickStyle = null;
142 this.lastNode.id = 'addLS' + addListStudioCount;
143 studiotabs.subtabModules[this.lastNode.id] = this.lastNode.module;
144 yahooSlots[this.lastNode.id] = new Studio2.ListDD(this.lastNode.id, 'subTabs', false);
145 addListStudioCount++;
146 this.lastNode.style.opacity = 1;
147 this.lastNode.style.filter = "alpha(opacity=100)";
149 this.lastNode = false;
152 dragEl.innerHTML = "";
155 onDrag: Studio2.onDrag,
157 onDragOver: function(e, id){
158 var el = document.getElementById(id);
161 * Limit number of columns in dashlets on 6!
163 var parent = el.parentNode.parentNode
164 if(studiotabs.view == 'dashlet'){
165 if(parent.id == 'Default'){
166 var cols = el.parentNode.getElementsByTagName("li");
167 if(cols.length > max_default_columns){
169 * Alert could be added but it will apear everytime when moving item over Defaults.
170 * Even when trying to change schedule of components inside of tab.
171 * alert('Maximum ' + max_default_columns + ' columns are allowed in Defaults tab!');
181 this.lastNode.parentNode.removeChild(this.lastNode);
182 this.lastNode = false;
184 if (id.substr(0, 7) == 'modSlot') {
187 el = document.getElementById(id);
188 dragEl = this.getDragEl();
190 var mid = YAHOO.util.Dom.getY(el) + (el.clientHeight / 2);
191 var el2 = this.getEl();
192 var p = el.parentNode;
193 if ((this.fromOnly || (el.id != 'trashcan' && el2.parentNode.id != p.id && el2.parentNode.id == this.parentID))) {
194 if (typeof(studiotabs.moduleTabs[p.id.substr(2, p.id.length)][studiotabs.subtabModules[el2.id]]) != 'undefined')
198 if (this.fromOnly && el.id != 'trashcan') {
199 el2 = el2.cloneNode(true);
200 el2.module = studiotabs.subtabModules[el2.id];
201 el2.id = 'addListStudio' + addListStudioCount;
203 this.lastNode.clickContent = el2.clickContent;
204 this.lastNode.clickBorder = el2.clickBorder;
205 this.lastNode.clickHeight = el2.clickHeight
208 if (YAHOO.util.Dom.getY(dragEl) < mid) { // insert on top triggering item
209 p.insertBefore(el2, el);
211 else { // insert below triggered item
212 p.insertBefore(el2, el.nextSibling);