Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Web/Components/GridComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/UI/Web/Components/GridComponent.js | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/GridComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/GridComponent.js index 51d55f4..21dddc9 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/GridComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/GridComponent.js | |||
@@ -1,70 +1,68 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); | 24 | Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); |
27 | 25 | ||
28 | Clipperz.PM.UI.Web.Components.GridComponent = function(args) { | 26 | Clipperz.PM.UI.Web.Components.GridComponent = function(args) { |
29 | args = args || {}; | 27 | args = args || {}; |
30 | 28 | ||
31 | Clipperz.PM.UI.Web.Components.GridComponent.superclass.constructor.apply(this, arguments); | 29 | Clipperz.PM.UI.Web.Components.GridComponent.superclass.constructor.apply(this, arguments); |
32 | 30 | ||
33 | this._columnsManagers = args.columnsManagers; | 31 | this._columnsManagers = args.columnsManagers; |
34 | 32 | ||
35 | this._rowsObjects = []; | 33 | this._rowsObjects = []; |
36 | this._noRowsGridComponent = null; | 34 | this._noRowsGridComponent = null; |
37 | 35 | ||
38 | this._slots = { | 36 | this._slots = { |
39 | 'headerSlot':this.getId('headerSlot') | 37 | 'headerSlot':this.getId('headerSlot') |
40 | }; | 38 | }; |
41 | 39 | ||
42 | return this; | 40 | return this; |
43 | } | 41 | } |
44 | 42 | ||
45 | //============================================================================= | 43 | //============================================================================= |
46 | 44 | ||
47 | Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.GridComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { | 45 | Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.GridComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { |
48 | 46 | ||
49 | //------------------------------------------------------------------------- | 47 | //------------------------------------------------------------------------- |
50 | 48 | ||
51 | 'toString': function () { | 49 | 'toString': function () { |
52 | return "Clipperz.PM.UI.Web.Components.GridComponent component"; | 50 | return "Clipperz.PM.UI.Web.Components.GridComponent component"; |
53 | }, | 51 | }, |
54 | 52 | ||
55 | //------------------------------------------------------------------------- | 53 | //------------------------------------------------------------------------- |
56 | 54 | ||
57 | 'rows': function () { | 55 | 'rows': function () { |
58 | throw Clipperz.Base.exception.AbstractMethod; | 56 | throw Clipperz.Base.exception.AbstractMethod; |
59 | // return this._rows; | 57 | // return this._rows; |
60 | }, | 58 | }, |
61 | 59 | ||
62 | //------------------------------------------------------------------------- | 60 | //------------------------------------------------------------------------- |
63 | 61 | ||
64 | 'columnsManagers': function () { | 62 | 'columnsManagers': function () { |
65 | return this._columnsManagers; | 63 | return this._columnsManagers; |
66 | }, | 64 | }, |
67 | 65 | ||
68 | //------------------------------------------------------------------------- | 66 | //------------------------------------------------------------------------- |
69 | 67 | ||
70 | 'renderSelf': function(/*aContainer, aPosition*/) { | 68 | 'renderSelf': function(/*aContainer, aPosition*/) { |
@@ -80,103 +78,101 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.GridComponent, Clipperz.PM.UI | |||
80 | ]} | 78 | ]} |
81 | ]}, | 79 | ]}, |
82 | {tag:'div', cls:'body', children:[ | 80 | {tag:'div', cls:'body', children:[ |
83 | {tag:'div', cls:'rows', id:this.getId('rows'), children:[ | 81 | {tag:'div', cls:'rows', id:this.getId('rows'), children:[ |
84 | {tag:'table', cellpadding:'0', cellspacing:'0', cls:'rows', children:[ | 82 | {tag:'table', cellpadding:'0', cellspacing:'0', cls:'rows', children:[ |
85 | {tag:'thead', children:[ | 83 | {tag:'thead', children:[ |
86 | {tag:'tr', id:this.getId('thead_tr'), children:[]} | 84 | {tag:'tr', id:this.getId('thead_tr'), children:[]} |
87 | ]}, | 85 | ]}, |
88 | {tag:'tbody', id:this.getId('gridRows'), children:[]} | 86 | {tag:'tbody', id:this.getId('gridRows'), children:[]} |
89 | ]} | 87 | ]} |
90 | ]}, | 88 | ]}, |
91 | {tag:'div', cls:'noRowsBlock', id:this.getId('noRowsBlock'), children:[]} | 89 | {tag:'div', cls:'noRowsBlock', id:this.getId('noRowsBlock'), children:[]} |
92 | ]}, | 90 | ]}, |
93 | {tag:'div', cls:'footer'} | 91 | {tag:'div', cls:'footer'} |
94 | ]); | 92 | ]); |
95 | 93 | ||
96 | this.renderHeader(); | 94 | this.renderHeader(); |
97 | MochiKit.Signal.connect(this.getId('clearSearch'), 'onclick', this, 'clearSearchHandler'); | 95 | MochiKit.Signal.connect(this.getId('clearSearch'), 'onclick', this, 'clearSearchHandler'); |
98 | }, | 96 | }, |
99 | 97 | ||
100 | //------------------------------------------------------------------------- | 98 | //------------------------------------------------------------------------- |
101 | 99 | ||
102 | 'renderHeader': function () { | 100 | 'renderHeader': function () { |
103 | var headerElement; | 101 | var headerElement; |
104 | 102 | ||
105 | headerElement = this.getElement('thead_tr'); | 103 | headerElement = this.getElement('thead_tr'); |
106 | headerElement.innerHTML = ""; | 104 | headerElement.innerHTML = ""; |
107 | 105 | ||
108 | MochiKit.Iter.forEach(this.columnsManagers(), function (aColumnManager) { | 106 | MochiKit.Iter.forEach(this.columnsManagers(), function (aColumnManager) { |
109 | aColumnManager.renderHeader(headerElement); | 107 | aColumnManager.renderHeader(headerElement); |
110 | }); | 108 | }); |
111 | }, | 109 | }, |
112 | 110 | ||
113 | //------------------------------------------------------------------------- | 111 | //------------------------------------------------------------------------- |
114 | 112 | ||
115 | 'update': function (someObjects) { | 113 | 'update': function (someObjects) { |
116 | this._rowsObjects = someObjects | 114 | this._rowsObjects = someObjects |
117 | this.refresh(); | 115 | this.refresh(); |
118 | this.focus(); | 116 | this.focus(); |
119 | }, | 117 | }, |
120 | 118 | ||
121 | 'focus': function () { | 119 | 'focus': function () { |
122 | this.getElement('search').focus(); | 120 | this.getElement('search').focus(); |
123 | }, | 121 | }, |
124 | 122 | ||
125 | //------------------------------------------------------------------------- | 123 | //------------------------------------------------------------------------- |
126 | 124 | ||
127 | 'startSearch': function () { | 125 | 'startSearch': function () { |
128 | //console.log("--> startSearch"); | ||
129 | MochiKit.DOM.addElementClass(this.getElement('search'), 'running'); | 126 | MochiKit.DOM.addElementClass(this.getElement('search'), 'running'); |
130 | }, | 127 | }, |
131 | 128 | ||
132 | 'endSearch': function () { | 129 | 'endSearch': function () { |
133 | MochiKit.DOM.removeElementClass(this.getElement('search'), 'running'); | 130 | MochiKit.DOM.removeElementClass(this.getElement('search'), 'running'); |
134 | //console.log("<-- startSearch"); | ||
135 | }, | 131 | }, |
136 | 132 | ||
137 | //------------------------------------------------------------------------- | 133 | //------------------------------------------------------------------------- |
138 | 134 | ||
139 | 'disconnectColumnManagersRowsSignals': function () { | 135 | 'disconnectColumnManagersRowsSignals': function () { |
140 | MochiKit.Iter.forEach(this.columnsManagers(), function (aColumnManager) { | 136 | MochiKit.Iter.forEach(this.columnsManagers(), function (aColumnManager) { |
141 | aColumnManager.disconnectRowsSignals(); | 137 | aColumnManager.disconnectRowsSignals(); |
142 | }); | 138 | }); |
143 | }, | 139 | }, |
144 | 140 | ||
145 | //------------------------------------------------------------------------- | 141 | //------------------------------------------------------------------------- |
146 | 142 | ||
147 | 'refresh': function () { | 143 | 'refresh': function () { |
148 | var gridRowsElement; | 144 | var gridRowsElement; |
149 | var rowClass; | 145 | var rowClass; |
150 | 146 | ||
151 | this.disconnectColumnManagersRowsSignals(); | 147 | this.disconnectColumnManagersRowsSignals(); |
152 | 148 | ||
153 | { | 149 | { |
154 | MochiKit.DOM.removeElementClass(this.getElement('search'), 'disabled'); | 150 | MochiKit.DOM.removeElementClass(this.getElement('search'), 'disabled'); |
155 | // MochiKit.DOM.setNodeAttribute(this.getElement('search'), 'disabled', null); | 151 | // MochiKit.DOM.setNodeAttribute(this.getElement('search'), 'disabled', null); |
156 | MochiKit.DOM.removeElementClass(this.element(), 'empty'); | 152 | MochiKit.DOM.removeElementClass(this.element(), 'empty'); |
157 | MochiKit.DOM.removeElementClass(this.element(), 'noRows'); | 153 | MochiKit.DOM.removeElementClass(this.element(), 'noRows'); |
158 | } | 154 | } |
159 | 155 | ||
160 | 156 | ||
161 | gridRowsElement = this.getElement('gridRows'); | 157 | gridRowsElement = this.getElement('gridRows'); |
162 | gridRowsElement.innerHTML = ""; | 158 | gridRowsElement.innerHTML = ""; |
163 | 159 | ||
164 | MochiKit.DOM.removeElementClass(this.element(), 'empty'); | 160 | MochiKit.DOM.removeElementClass(this.element(), 'empty'); |
165 | 161 | ||
166 | rowClass = 'odd'; | 162 | rowClass = 'odd'; |
167 | MochiKit.Iter.forEach(this._rowsObjects, MochiKit.Base.bind(function (aRowObject) { | 163 | MochiKit.Iter.forEach(this._rowsObjects, MochiKit.Base.bind(function (aRowObject) { |
168 | var cardRowElement; | 164 | var cardRowElement; |
169 | 165 | ||
170 | cardRowElement = this.append(gridRowsElement, {tag:'tr', id:this.getId(aRowObject['_reference']), cls:rowClass}); | 166 | cardRowElement = this.append(gridRowsElement, {tag:'tr', id:this.getId(aRowObject['_reference']), cls:rowClass}); |
171 | MochiKit.Iter.forEach(this.columnsManagers(), function (aColumnManager) { | 167 | MochiKit.Iter.forEach(this.columnsManagers(), function (aColumnManager) { |
172 | aColumnManager.renderCell(cardRowElement, aRowObject); | 168 | aColumnManager.renderCell(cardRowElement, aRowObject); |
173 | }); | 169 | }); |
174 | 170 | ||
175 | rowClass = (rowClass == 'odd') ? 'even' : 'odd'; | 171 | rowClass = (rowClass == 'odd') ? 'even' : 'odd'; |
176 | }, this)); | 172 | }, this)); |
177 | }, | 173 | }, |
178 | 174 | ||
179 | //----------------------------------------------------------------------------- | 175 | //----------------------------------------------------------------------------- |
180 | 176 | ||
181 | 'filterElement': function () { | 177 | 'filterElement': function () { |
182 | return this.getElement('search'); | 178 | return this.getElement('search'); |