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 ********************************************************************************/
39 if(typeof('console') == 'undefined'){
41 log: function(message) {
47 StudioTabGroup = function(){
49 this.lastEditTabGroupLabel = -1;
50 this.widths = new Object;
54 StudioTabGroup.prototype.editTabGroupLabel = function (id, 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();
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();
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++) {
80 if(typeof(studiotabs.subtabModules[items[i].id]) != 'undefined'){
82 var input = document.createElement('input');
84 input.name= j + '_'+ i;
85 input.value = studiotabs.tabLabelToValue[studiotabs.subtabModules[items[i].id]];
86 form.appendChild(input);
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');
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);
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]);
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;
133 document.getElementById('ul' + id).style.display = '';
134 document.getElementById('tabname_'+id).style.textDecoration = 'none'
135 document.getElementById('delete_' + id).value = 0;
139 StudioTabGroup.prototype.editField = function(elem, link) {
140 if (this.widths[elem.id] != null) {
141 ModuleBuilder.getContent(link + '&width=' + this.widths[elem.id]);
143 ModuleBuilder.getContent(link);
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;
157 if (inputs[i].name == "label") {
158 var title = elem.getElementsByTagName("span")[0];
159 title.innerHTML = inputs[i].value;
162 ModuleBuilder.submitForm(formname);
163 ajaxStatus.flashStatus('Field Saved', 1000);
166 StudioTabGroup.prototype.reset = function() {
167 this.subtabCount = {};
168 this.subtabModules = {};
169 this.tabLabelToValue = {};
170 this.widths = new Object;
174 var lastRowCount = -1;
175 var undoDeleteDropDown = function(transaction){
176 deleteDropDownValue(transaction['row'], document.getElementById(transaction['id']), false);
178 jstransaction.register('deleteDropDown', undoDeleteDropDown, undoDeleteDropDown);
179 function deleteDropDownValue(rowCount, field, record){
181 jstransaction.record('deleteDropDown',{'row':rowCount, 'id': field.id });
183 //We are deleting if the value is 0
184 if(field.value == '0'){
186 document.getElementById('slot' + rowCount + '_value').style.textDecoration = 'line-through';
189 document.getElementById('slot' + rowCount + '_value').style.textDecoration = 'none';
194 var studiotabs = new StudioTabGroup();
195 studiotabs.subtabCount = {};
196 studiotabs.subtabModules = {};
197 studiotabs.tabLabelToValue = {};