]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/ModuleBuilder/javascript/studiotabgroups.js
Release 6.5.0
[Github/sugarcrm.git] / modules / ModuleBuilder / javascript / studiotabgroups.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 if(typeof('console') == 'undefined'){
40 console = {
41         log: function(message) {
42         
43         }
44 }
45 }
46
47 StudioTabGroup = function(){
48         this.fields = {};
49         this.lastEditTabGroupLabel = -1;
50         this.widths = new Object;
51 };
52
53
54 StudioTabGroup.prototype.editTabGroupLabel = function (id, done){
55         if(!done){
56                 if(this.lastEditTabGroupLabel != -1)editTabGroupLabel(this.lastEditTabGroupLabel, true);
57                 document.getElementById('tabname_'+id).style.display = 'none';
58                 document.getElementById('tablabel_'+id).style.display = '';
59                 document.getElementById('tabother_'+id).style.display = 'none';
60                 document.getElementById('tablabel_'+id).focus();
61                 this.lastEditTabGroupLabel = id;
62                 //Ext.dd.DragDropMgr.lock();
63         }else{
64                 this.lastEditTabGroupLabel = -1;
65                 document.getElementById('tabname_'+id).innerHTML = escape(document.getElementById('tablabel_'+id).value);
66                 document.getElementById('tabname_'+id).style.display = '';
67                 document.getElementById('tablabel_'+id).style.display = 'none';
68                 document.getElementById('tabother_'+id).style.display = '';
69                 //Ext.dd.DragDropMgr.unlock();
70         }
71 }
72
73  StudioTabGroup.prototype.generateForm = function(formname){
74                         var form = document.getElementById(formname);
75                         for(j = 0; j < studiotabs.slotCount; j++){
76                                 var ul = document.getElementById('ul' + j);
77                                 items = ul.getElementsByTagName('li');
78                                 for(i = 0; i < items.length; i++) {
79                                 
80                                 if(typeof(studiotabs.subtabModules[items[i].id]) != 'undefined'){
81                                 
82                                         var input = document.createElement('input');
83                                         input.type='hidden'
84                                         input.name= j + '_'+ i;
85                                         input.value = studiotabs.tabLabelToValue[studiotabs.subtabModules[items[i].id]];
86                                         form.appendChild(input);
87                                 }
88                                 }
89                   }
90                   };
91
92  StudioTabGroup.prototype.generateGroupForm = function(formname){
93                         this.clearGroupForm(formname);
94                         var form = document.getElementById(formname);
95                         for(j = 0; j < studiotabs.slotCount; j++){
96                                 var ul = document.getElementById('ul' + j);
97                                 items = ul.getElementsByTagName('li');
98                                 for(i = 0; i < items.length; i++) {
99                                 if(typeof(studiotabs.subtabModules[items[i].id]) != 'undefined'){
100                                         var input = document.createElement('input');
101                                         input.type='hidden';
102                                         input.name= 'group_'+ j + '[]';
103                                         input.value = studiotabs.tabLabelToValue[studiotabs.subtabModules[items[i].id]];
104                                         form.appendChild(input);
105 //                                      if(this.widths[items[i].id] != null) {
106                                         var winput = document.createElement('input');
107                                         winput.type='hidden';
108                                         winput.name= input.value + 'width';
109                                         winput.value = "width=" + document.getElementById(items[i].id+'width').innerHTML;
110                                         form.appendChild(winput);
111 //                                      }
112                                 }
113                                 }
114                         }
115                   };
116                   
117 StudioTabGroup.prototype.clearGroupForm = function(formname){
118                 var form = document.getElementById(formname);
119                 for(j = 0; j < form.elements.length; j++){
120                         if (typeof(form.elements[j].name) != 'undefined' && String(form.elements[j].name).indexOf("group") > -1) {
121                                 form.removeChild(form.elements[j]);
122                                 j--;
123                         }
124                 }
125 };
126
127 StudioTabGroup.prototype.deleteTabGroup = function(id){
128                 if(document.getElementById('delete_' + id).value == 0){
129                         document.getElementById('ul' + id).style.display = 'none';
130                         document.getElementById('tabname_'+id).style.textDecoration = 'line-through'
131                         document.getElementById('delete_' + id).value = 1;
132                 }else{
133                         document.getElementById('ul' + id).style.display = '';
134                         document.getElementById('tabname_'+id).style.textDecoration = 'none'
135                         document.getElementById('delete_' + id).value = 0;
136                 }
137         }       
138
139 StudioTabGroup.prototype.editField = function(elem, link) {
140         if (this.widths[elem.id] != null) {
141                 ModuleBuilder.getContent(link + '&width=' + this.widths[elem.id]);
142         }else{
143                 ModuleBuilder.getContent(link);
144         }
145 }
146
147 StudioTabGroup.prototype.saveField = function(elemID, formname) {
148         var elem = document.getElementById(elemID);
149         var form = document.getElementById(formname);
150         var inputs = form.getElementsByTagName("input");
151         for (i = 0; i < inputs.length; i++) {
152                 if (inputs[i].name == "width") {
153                         this.widths[elemID] = inputs[i].value;
154                         var dispWidth = elem.getElementsByTagName("td")[3];
155                         dispWidth.innerHTML = "width:" + inputs[i].value;
156                 }
157                 if (inputs[i].name == "label") {
158                         var title = elem.getElementsByTagName("span")[0];
159                         title.innerHTML = inputs[i].value;
160                 }
161         }
162         ModuleBuilder.submitForm(formname);
163         ajaxStatus.flashStatus('Field Saved', 1000);
164 }
165
166 StudioTabGroup.prototype.reset = function() {
167         this.subtabCount = {};
168         this.subtabModules = {};
169         this.tabLabelToValue = {};
170         this.widths = new Object;
171 }
172
173 var lastField = '';
174                         var lastRowCount = -1;
175                         var undoDeleteDropDown = function(transaction){
176                             deleteDropDownValue(transaction['row'], document.getElementById(transaction['id']), false);
177                         }
178                         jstransaction.register('deleteDropDown', undoDeleteDropDown, undoDeleteDropDown);
179                         function deleteDropDownValue(rowCount, field, record){
180                             if(record){
181                                 jstransaction.record('deleteDropDown',{'row':rowCount, 'id': field.id });
182                             }
183                             //We are deleting if the value is 0
184                             if(field.value == '0'){
185                                 field.value = '1';
186                                 document.getElementById('slot' + rowCount + '_value').style.textDecoration = 'line-through';
187                             }else{
188                                 field.value = '0';
189                                 document.getElementById('slot' + rowCount + '_value').style.textDecoration = 'none';
190                             }
191                             
192                            
193                         }
194 var studiotabs = new StudioTabGroup();
195 studiotabs.subtabCount = {};
196 studiotabs.subtabModules = {};
197 studiotabs.tabLabelToValue = {};