summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js15
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js
index 9162867..aa57580 100644
--- a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js
@@ -1,189 +1,186 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz's Javascript Crypto Library. 5This file is part of Clipperz Community Edition.
6Javascript Crypto Library provides web developers with an extensive 6Clipperz Community Edition is an online password manager.
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please 7For further information about its features and functionalities please
11refer to http://www.clipperz.com 8refer to http://www.clipperz.com.
12 9
13* Javascript Crypto Library is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public 11 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
17 14
18* Javascript Crypto Library is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
22 19
23* You should have received a copy of the GNU Affero General Public 20* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see 21 License along with Clipperz Community Edition. If not, see
25 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
26 23
27*/ 24*/
28 25
29if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } 26if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
30if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } 27if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
31if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } 28if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; }
32if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } 29if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; }
33if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } 30if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; }
34 31
35//############################################################################# 32//#############################################################################
36 33
37Clipperz.PM.Components.Import.CSVImport.CSVImportTitle = function(anElement, args) { 34Clipperz.PM.Components.Import.CSVImport.CSVImportTitle = function(anElement, args) {
38 args = args || {}; 35 args = args || {};
39 36
40 Clipperz.PM.Components.Import.CSVImport.CSVImportTitle.superclass.constructor.call(this, anElement, args); 37 Clipperz.PM.Components.Import.CSVImport.CSVImportTitle.superclass.constructor.call(this, anElement, args);
41 this._mainComponent = args.mainComponent; 38 this._mainComponent = args.mainComponent;
42 39
43 return this; 40 return this;
44} 41}
45 42
46//============================================================================= 43//=============================================================================
47 44
48YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportTitle, Clipperz.PM.Components.BaseComponent, { 45YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportTitle, Clipperz.PM.Components.BaseComponent, {
49 46
50 'toString': function() { 47 'toString': function() {
51 return "Clipperz.PM.Components.Import.CSVImport.CSVImportTitle component"; 48 return "Clipperz.PM.Components.Import.CSVImport.CSVImportTitle component";
52 }, 49 },
53 50
54 //------------------------------------------------------------------------- 51 //-------------------------------------------------------------------------
55 52
56 'mainComponent': function() { 53 'mainComponent': function() {
57 return this._mainComponent; 54 return this._mainComponent;
58 }, 55 },
59 56
60 //------------------------------------------------------------------------- 57 //-------------------------------------------------------------------------
61 58
62 'render': function() { 59 'render': function() {
63 vartitleSelectorCheckboxCells; 60 vartitleSelectorCheckboxCells;
64 var titleColumnIndex; 61 var titleColumnIndex;
65 var i,c; 62 var i,c;
66 63
67 Clipperz.NotificationCenter.unregister(this); 64 Clipperz.NotificationCenter.unregister(this);
68 MochiKit.Signal.disconnectAllTo(this); 65 MochiKit.Signal.disconnectAllTo(this);
69 66
70 this.element().update(""); 67 this.element().update("");
71 68
72 titleColumnIndex = this.mainComponent().titleColumnIndex() 69 titleColumnIndex = this.mainComponent().titleColumnIndex()
73 titleSelectorCheckboxCells = []; 70 titleSelectorCheckboxCells = [];
74 c =this.mainComponent().parsedValues()[0].length; 71 c =this.mainComponent().parsedValues()[0].length;
75 for (i=0; i<c; i++) { 72 for (i=0; i<c; i++) {
76 if (this.mainComponent().isColumnSelected(i)) { 73 if (this.mainComponent().isColumnSelected(i)) {
77 titleSelectorCheckboxCells.push({tag:'th', valign:'top', id:this.getId('th_' + i), children:[ 74 titleSelectorCheckboxCells.push({tag:'th', valign:'top', id:this.getId('th_' + i), children:[
78 {tag:'input', type:'radio', id:this.getId('radio_' + i), name:'CSVImportTitleColumn', value:i}, 75 {tag:'input', type:'radio', id:this.getId('radio_' + i), name:'CSVImportTitleColumn', value:i},
79 {tag:'span', cls:'clickableSpan', id:this.getId('columnLabel_' + i), html:this.mainComponent().labelForColumn(i)} 76 {tag:'span', cls:'clickableSpan', id:this.getId('columnLabel_' + i), html:this.mainComponent().labelForColumn(i)}
80 ]}) 77 ]})
81 } 78 }
82 } 79 }
83 80
84 if (titleColumnIndex >= titleSelectorCheckboxCells.length) { 81 if (titleColumnIndex >= titleSelectorCheckboxCells.length) {
85 this.mainComponent().setTitleColumnIndex(-1); 82 this.mainComponent().setTitleColumnIndex(-1);
86 } 83 }
87 84
88 this.domHelper().append(this.element(), {tag:'div', children:[ 85 this.domHelper().append(this.element(), {tag:'div', children:[
89 {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Title']}, 86 {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Title']},
90 {tag:'div', id:this.getId('dataDiv'), cls:'csvImportPreview', children:[ 87 {tag:'div', id:this.getId('dataDiv'), cls:'csvImportPreview', children:[
91 {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[ 88 {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[
92 {tag:'thead', id:this.getId('previewData_thead'), children:[ 89 {tag:'thead', id:this.getId('previewData_thead'), children:[
93 {tag:'tr', children:titleSelectorCheckboxCells} 90 {tag:'tr', children:titleSelectorCheckboxCells}
94 ]}, 91 ]},
95 {tag:'tbody', id:this.getId('previewData_tbody'), children:[]} 92 {tag:'tbody', id:this.getId('previewData_tbody'), children:[]}
96 ]} 93 ]}
97 ]} 94 ]}
98 ]}); 95 ]});
99 96
100 this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); 97 this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues());
101 98
102 c =this.mainComponent().parsedValues()[0].length; 99 c =this.mainComponent().parsedValues()[0].length;
103 for (i=0; i<c; i++) { 100 for (i=0; i<c; i++) {
104 if (this.mainComponent().isColumnSelected(i)) { 101 if (this.mainComponent().isColumnSelected(i)) {
105 MochiKit.Signal.connect(this.getDom('radio_' + i), 'onclick', this, 'renderDataHandler'); 102 MochiKit.Signal.connect(this.getDom('radio_' + i), 'onclick', this, 'renderDataHandler');
106 if (Clipperz_IEisBroken != true) { 103 if (Clipperz_IEisBroken != true) {
107 MochiKit.Signal.connect(this.getDom('columnLabel_' + i), 'onclick', this.getDom('radio_' + i), 'click'); 104 MochiKit.Signal.connect(this.getDom('columnLabel_' + i), 'onclick', this.getDom('radio_' + i), 'click');
108 } 105 }
109 } 106 }
110 } 107 }
111 108
112 if (titleColumnIndex != -1) { 109 if (titleColumnIndex != -1) {
113 this.getDom('radio_' + titleColumnIndex).click(); 110 this.getDom('radio_' + titleColumnIndex).click();
114 } else { 111 } else {
115 this.mainComponent().nextButton().disable(); 112 this.mainComponent().nextButton().disable();
116 } 113 }
117 114
118 }, 115 },
119 116
120 //------------------------------------------------------------------------- 117 //-------------------------------------------------------------------------
121 118
122 'renderData': function(anElement, someData) { 119 'renderData': function(anElement, someData) {
123 var data; 120 var data;
124 var config; 121 var config;
125 var titleColumnIndex; 122 var titleColumnIndex;
126 var i,c; 123 var i,c;
127 124
128 // anElement.update(""); 125 // anElement.update("");
129 MochiKit.DOM.replaceChildNodes(anElement.dom); 126 MochiKit.DOM.replaceChildNodes(anElement.dom);
130 127
131 titleColumnIndex = this.mainComponent().titleColumnIndex() 128 titleColumnIndex = this.mainComponent().titleColumnIndex()
132 129
133 if (this.mainComponent().isFirstRowHeader()) { 130 if (this.mainComponent().isFirstRowHeader()) {
134 data = someData.slice(1); 131 data = someData.slice(1);
135 } else { 132 } else {
136 data = someData; 133 data = someData;
137 } 134 }
138 135
139 config = MochiKit.Base.map(MochiKit.Base.bind(function(aRowData) { 136 config = MochiKit.Base.map(MochiKit.Base.bind(function(aRowData) {
140 var result; 137 var result;
141 var i,c; 138 var i,c;
142 139
143 result = {tag:'tr', children:[]}; 140 result = {tag:'tr', children:[]};
144 c = aRowData.length; 141 c = aRowData.length;
145 for (i=0; i<c; i++) { 142 for (i=0; i<c; i++) {
146 if (this.mainComponent().isColumnSelected(i)) { 143 if (this.mainComponent().isColumnSelected(i)) {
147 var field; 144 var field;
148 145
149 field = aRowData[i]; 146 field = aRowData[i];
150 result.children.push({tag:'td', valign:'top', cls:((titleColumnIndex == i) ? 'titleColumn': ''), html:(MochiKit.Base.isNotEmpty(field) ? field.replace(/\n/g, '<br>') : '&nbsp;')}); 147 result.children.push({tag:'td', valign:'top', cls:((titleColumnIndex == i) ? 'titleColumn': ''), html:(MochiKit.Base.isNotEmpty(field) ? field.replace(/\n/g, '<br>') : '&nbsp;')});
151 } 148 }
152 } 149 }
153 150
154 return result; 151 return result;
155 }, this), data); 152 }, this), data);
156 153
157 MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config); 154 MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config);
158 155
159 Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); 156 Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada'));
160 }, 157 },
161 158
162 //------------------------------------------------------------------------- 159 //-------------------------------------------------------------------------
163 160
164 'renderDataHandler': function(anEvent) { 161 'renderDataHandler': function(anEvent) {
165 var i,c; 162 var i,c;
166 163
167 this.mainComponent().setTitleColumnIndex(anEvent.src().value); 164 this.mainComponent().setTitleColumnIndex(anEvent.src().value);
168 165
169 c = this.mainComponent().parsedValues()[0].length; 166 c = this.mainComponent().parsedValues()[0].length;
170 for (i=0; i<c; i++) { 167 for (i=0; i<c; i++) {
171 if (this.mainComponent().isColumnSelected(i)) { 168 if (this.mainComponent().isColumnSelected(i)) {
172 this.getElement('th_' + i).removeClass('titleColumn'); 169 this.getElement('th_' + i).removeClass('titleColumn');
173 } 170 }
174 } 171 }
175 this.getElement('th_' + anEvent.src().value).addClass('titleColumn'); 172 this.getElement('th_' + anEvent.src().value).addClass('titleColumn');
176 173
177 if (anEvent.src().value != -1) { 174 if (anEvent.src().value != -1) {
178 this.mainComponent().nextButton().enable(); 175 this.mainComponent().nextButton().enable();
179 } else { 176 } else {
180 this.mainComponent().nextButton().disable(); 177 this.mainComponent().nextButton().disable();
181 } 178 }
182 179
183 this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); 180 this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues());
184 }, 181 },
185 182
186 //------------------------------------------------------------------------- 183 //-------------------------------------------------------------------------
187 __syntaxFix__: "syntax fix" 184 __syntaxFix__: "syntax fix"
188}); 185});
189 186