]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/modules/Studio/studiotabgroups.js
Release 6.5.0
[Github/sugarcrm.git] / jssource / src_files / modules / Studio / 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 var subtabCount = [];
39 var subtabModules = [];
40 var tabLabelToValue = [];
41 StudioTabGroup = function(){
42         this.lastEditTabGroupLabel = -1;
43 };
44
45
46 StudioTabGroup.prototype.editTabGroupLabel = function (id, done){
47         if(!done){
48                 if(this.lastEditTabGroupLabel != -1)StudioTabGroup.prototype.editTabGroupLabel(this.lastEditTabGroupLabel, true);
49                 document.getElementById('tabname_'+id).style.display = 'none';
50                 document.getElementById('tablabel_'+id).style.display = '';
51                 document.getElementById('tabother_'+id).style.display = 'none';
52                 //#28274, I think this is a simple way when a element can't accept focus()
53                 try{
54                         document.getElementById('tablabel_'+id).focus();
55                 }
56                 catch(er){
57                         //TODO
58                 }
59                 this.lastEditTabGroupLabel = id;
60                 YAHOO.util.DragDropMgr.lock();
61         }else{
62                 this.lastEditTabGroupLabel = -1;
63                 document.getElementById('tabname_'+id).innerHTML = escape(document.getElementById('tablabel_'+id).value);
64                 document.getElementById('tabname_'+id).style.display = '';
65                 document.getElementById('tablabel_'+id).style.display = 'none';
66                 document.getElementById('tabother_'+id).style.display = '';
67                 YAHOO.util.DragDropMgr.unlock();
68         }
69 }
70
71  StudioTabGroup.prototype.generateForm = function(formname){
72         var form = document.getElementById(formname);
73         for(var j = 0; j < slotCount; j++){
74                 var ul = document.getElementById('ul' + j);
75                 var items = ul.getElementsByTagName('li');
76                 for(var i = 0; i < items.length; i++) {
77                     if(typeof(subtabModules[items[i].id]) != 'undefined'){
78                         
79                                 var input = document.createElement('input');
80                                 input.type='hidden';
81                                 input.name= j + '_'+ i;
82                                 input.value = tabLabelToValue[subtabModules[items[i].id]];
83                                 form.appendChild(input);
84                         }
85                 }
86     }
87         //set the slotcount in the form.
88         form.slot_count.value = slotCount;
89 };
90
91  StudioTabGroup.prototype.generateGroupForm = function(formname){
92                         var form = document.getElementById(formname);
93                         for(j = 0; j < slotCount; j++){
94                                 var ul = document.getElementById('ul' + j);
95                                 items = ul.getElementsByTagName('li');
96                                 for(i = 0; i < items.length; i++) {
97                                 if(typeof(subtabModules[items[i].id]) != 'undefined'){
98                                         var input = document.createElement('input');
99                                         input.type='hidden'
100                                         input.name= 'group_'+ j + '[]';
101                                         input.value = tabLabelToValue[subtabModules[items[i].id]];
102                                         form.appendChild(input);
103                                 }
104                                 }
105                   }
106                   };
107
108 StudioTabGroup.prototype.deleteTabGroup = function(id){
109                 if(document.getElementById('delete_' + id).value == 0){
110                         document.getElementById('ul' + id).style.display = 'none';
111                         document.getElementById('tabname_'+id).style.textDecoration = 'line-through'
112                         document.getElementById('delete_' + id).value = 1;
113                 }else{
114                         document.getElementById('ul' + id).style.display = '';
115                         document.getElementById('tabname_'+id).style.textDecoration = 'none'
116                         document.getElementById('delete_' + id).value = 0;
117                 }
118         }       
119
120
121 var lastField = '';
122                         var lastRowCount = -1;
123                         var undoDeleteDropDown = function(transaction){
124                             deleteDropDownValue(transaction['row'], document.getElementById(transaction['id']), false);
125                         }
126                         jstransaction.register('deleteDropDown', undoDeleteDropDown, undoDeleteDropDown);
127                         function deleteDropDownValue(rowCount, field, record){
128                             if(record){
129                                 jstransaction.record('deleteDropDown',{'row':rowCount, 'id': field.id });
130                             }
131                             //We are deleting if the value is 0
132                             if(field.value == '0'){
133                                 field.value = '1';
134                                 document.getElementById('slot' + rowCount + '_value').style.textDecoration = 'line-through';
135                             }else{
136                                 field.value = '0';
137                                 document.getElementById('slot' + rowCount + '_value').style.textDecoration = 'none';
138                             }
139                             
140                            
141                         }
142 var studiotabs = new StudioTabGroup();