author | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
commit | 541bb378ddece2eab135a8066a16994e94436dea (patch) (unidiff) | |
tree | ff160ea3e26f7fe07fcfd401387c5a0232ca715e /frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardList.js | |
parent | 1bf431fd3d45cbdf4afa3e12afefe5d24f4d3bc7 (diff) | |
parent | ecad5e895831337216544e81f1a467e0c68c4a6a (diff) | |
download | clipperz-541bb378ddece2eab135a8066a16994e94436dea.zip clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.gz clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.bz2 |
Merge pull request #1 from gcsolaroli/master
First version of the restructured repository
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardList.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardList.js | 204 |
1 files changed, 204 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardList.js b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardList.js new file mode 100644 index 0000000..770f983 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardList.js | |||
@@ -0,0 +1,204 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | ||
11 | refer to http://www.clipperz.com | ||
12 | |||
13 | * Javascript Crypto Library is free software: you can redistribute | ||
14 | 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 | ||
16 | 3 of the License, or (at your option) any later version. | ||
17 | |||
18 | * Javascript Crypto Library is distributed in the hope that it will | ||
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
21 | See the GNU Affero General Public License for more details. | ||
22 | |||
23 | * You should have received a copy of the GNU Affero General Public | ||
24 | License along with Javascript Crypto Library. If not, see | ||
25 | <http://www.gnu.org/licenses/>. | ||
26 | |||
27 | */ | ||
28 | |||
29 | Clipperz.Base.module('Clipperz.PM.UI.iPhone.Components'); | ||
30 | |||
31 | Clipperz.PM.UI.iPhone.Components.CardList = function(args) { | ||
32 | args = args || {}; | ||
33 | |||
34 | Clipperz.PM.UI.iPhone.Components.CardList.superclass.constructor.apply(this, arguments); | ||
35 | |||
36 | this._cardDetail = null; | ||
37 | |||
38 | return this; | ||
39 | } | ||
40 | |||
41 | //============================================================================= | ||
42 | |||
43 | Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardList, Clipperz.PM.UI.Common.Components.BaseComponent, { | ||
44 | |||
45 | //------------------------------------------------------------------------- | ||
46 | |||
47 | 'toString': function () { | ||
48 | return "Clipperz.PM.UI.iPhone.Components.CardList component"; | ||
49 | }, | ||
50 | |||
51 | //------------------------------------------------------------------------- | ||
52 | |||
53 | 'renderSelf': function(/*aContainer, aPosition*/) { | ||
54 | this.append(this.element(), [ | ||
55 | {tag:'div', cls:'toolbar', id:'toolbar', children:[ | ||
56 | {tag:'h1', id:'pageTitle', html:"cards"}, | ||
57 | {tag:'a', id:'backButton', cls:'button', href:'#', html:"cards"} | ||
58 | ]}, | ||
59 | {tag:'div', cls:'cardList', id:this.getId('cardList'), children:[ | ||
60 | {tag:'form', title:'search', cls:'panel cardListSearchForm', id:this.getId('cardListSearchForm'), children:[ | ||
61 | {tag:'input', type:'search', name:'search', value:"", placeholder:"search", id:this.getId('searchField')} | ||
62 | ]}, | ||
63 | {tag:'ul', cls:'panel cardListPanel', id:this.getId('cardListPanel'), children:[]} | ||
64 | ]}, | ||
65 | {tag:'div', cls:'panel cardDetailPanel', id:this.getId('cardDetail')} | ||
66 | ]); | ||
67 | |||
68 | MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onsubmit', this,'searchHandler'); | ||
69 | MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeydown', this,'searchHandler'); | ||
70 | MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeyup', this,'searchHandler'); | ||
71 | |||
72 | MochiKit.Signal.connect(this.getElement('cardListPanel'), 'onclick', this,'cardListClickHandler'); | ||
73 | MochiKit.Signal.connect('backButton', 'onclick', this,'backButtonClickHandler'); | ||
74 | |||
75 | MochiKit.Style.hideElement('backButton'); | ||
76 | MochiKit.Style.hideElement(this.getElement('cardDetail')); | ||
77 | }, | ||
78 | |||
79 | //------------------------------------------------------------------------- | ||
80 | |||
81 | 'searchHandler': function (anEvent) { | ||
82 | if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ENTER')) { //RETURN | ||
83 | anEvent.preventDefault(); | ||
84 | } else { | ||
85 | if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ESCAPE')) { | ||
86 | anEvent.target().value = ""; | ||
87 | } | ||
88 | |||
89 | if (anEvent.type() == 'keyup') { | ||
90 | MochiKit.Signal.signal(this, 'searchEvent', anEvent.target().value); | ||
91 | } | ||
92 | } | ||
93 | }, | ||
94 | |||
95 | //------------------------------------------------------------------------- | ||
96 | |||
97 | 'update': function (someObjects) { | ||
98 | varcardListPanel; | ||
99 | var i,c; | ||
100 | |||
101 | cardListPanel = this.getElement('cardListPanel'); | ||
102 | cardListPanel.innerHTML = ''; | ||
103 | |||
104 | c = someObjects.length; | ||
105 | |||
106 | for (i=0; i<c; i++) { | ||
107 | this.append(cardListPanel, {tag:'li', cls:'cardListItem', id:('cardListItem_' + someObjects[i]['_reference']), children:[ | ||
108 | {tag:'img', src:(someObjects[i]['favicon'] ? someObjects[i]['favicon'] : 'data:application/octet-stream;charset=utf-8;base64,AAABAAEAFxcAAAEAGAD8BgAAFgAAACgAAAAXAAAALgAAAAEAGAAAAAAAAAAAABIXAAASFwAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////9zAC////////////////////////////////////////////////////////////////////////////////////////////9pAG////////////////////////////////////////////////////////////////////////////////////////////9rAC////////////////////////////////////////////////////////////////////////////////////////////9yAHP////////////////////////IyMizs7O6urrq6ur////////////Ozs6zs7Ozs7Pq6ur///////////////////////8AAAD////////////////////V1dWXl5eXl5eXl5elpaX4+Pj////Ozs6Xl5eXl5eXl5eenp7///////////////////////8AAAD////////////////////Ozs6Xl5eXl5eXl5eXl5fBwcHq6uqenp6Xl5eXl5eXl5eXl5f///////////////////////8AAAD////////////////////j4+OXl5eXl5eXl5eXl5eXl5elpaWXl5eXl5eXl5eXl5ezs7P///////////////////////8AAAD////////////////////////IyMiXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eenp7x8fH////////////////////////////////////////////////////4+PilpaWXl5eXl5eXl5eXl5eXl5eXl5eXl5fOzs7////////////////////////////////////////////////////////q6uq6urqXl5eXl5eXl5eXl5eXl5eXl5eenp7V1dX4+Pj///////////////////////8AAAD////////////4+PjOzs6lpaWXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5e6urrj4+P///////////////8AAAD////////////BwcGXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5fx8fH///////////8AAAD///////////+zs7OXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5fj4+P///////////8AAAD////////////IyMiXl5eXl5eXl5eXl5e6urqXl5eXl5eXl5eXl5esrKylpaWXl5eXl5eXl5eenp7x8fH///////////8AAAD////////////////Ozs7Ozs7V1dX4+Pj///+Xl5eXl5eXl5eXl5fOzs7////q6urOzs7Ozs7q6ur///////////////8AAAD///////////////////////////////////+Xl5eXl5eXl5eXl5fOzs7///////////////////////////////////8AAAD///////////////////////////////////+Xl5eXl5eXl5eXl5fOzs7///////////////////////////////////8AAAD///////////////////////////////////+Xl5eXl5eXl5eXl5fOzs7///////////////////////////////////8AAAD////////////////////////////////////IyMiXl5eXl5eenp7x8fH///////////////////////////////////8AAAD////////////////////////////////////////j4+Pj4+Px8fH///////////////////////////////////////8AAAD///////////////////////////////////////////////////////////////////////////////////////////8AAAD///////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAo=')}, | ||
109 | {tag:'a', id:('cardListReference_' + someObjects[i]['_reference']), href:'#', html:someObjects[i]['label']} | ||
110 | ]}) | ||
111 | |||
112 | MochiKit.Signal.connect('cardListItem_' + someObjects[i]['_reference'], 'onclick', this, 'cardListClickHandler'); | ||
113 | } | ||
114 | |||
115 | }, | ||
116 | |||
117 | 'cardListClickHandler': function (anEvent) { | ||
118 | anEvent.preventDefault(); | ||
119 | |||
120 | if (/(cardListReference_|cardListItem_)/.test(anEvent.target().id)) { | ||
121 | var cardListReference; | ||
122 | |||
123 | cardListReference = anEvent.target().id.match(/(cardListReference_|cardListItem_)(.*)/)[2]; | ||
124 | //console.log("Showing detail for card named", cardListReference); | ||
125 | MochiKit.Signal.signal(this, 'selectedCard', cardListReference); | ||
126 | } | ||
127 | }, | ||
128 | |||
129 | //========================================================================= | ||
130 | |||
131 | 'cardDetail': function (someData) { | ||
132 | if (this._cardDetail == null) { | ||
133 | this._cardDetail = new Clipperz.PM.UI.iPhone.Components.CardDetail({element:this.getElement('cardDetail')}); | ||
134 | } | ||
135 | |||
136 | return this._cardDetail; | ||
137 | }, | ||
138 | |||
139 | //------------------------------------------------------------------------- | ||
140 | |||
141 | 'removeCardDetail': function () { | ||
142 | if (this._cardDetail != null) { | ||
143 | this._cardDetail.remove(); | ||
144 | this._cardDetail = null; | ||
145 | } | ||
146 | }, | ||
147 | |||
148 | //========================================================================= | ||
149 | |||
150 | 'showCard': function (someData) { | ||
151 | vardeferredResult; | ||
152 | varoffset; | ||
153 | |||
154 | offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480); | ||
155 | this.cardDetail().render(); | ||
156 | this.cardDetail().setCardReference(someData['_reference']); | ||
157 | MochiKit.Style.setElementPosition(this.cardDetail().element(), {x:offset}); | ||
158 | new MochiKit.Visual.Sequence([ | ||
159 | // new MochiKit.Visual.Move(this.cardDetail().element(), {x:offset, y:45, mode:'absolute', duration:0, sync:true}), | ||
160 | new MochiKit.Visual.Parallel([ | ||
161 | new MochiKit.Visual.Move(this.getElement('cardList'), {x:-offset, y:0, mode:'relative',transition:MochiKit.Visual.Transitions.linear, sync:true}), | ||
162 | new MochiKit.Visual.Move(this.getElement('cardDetail'), {x:0, y:45, mode:'absolute',transition:MochiKit.Visual.Transitions.linear, sync:true}), | ||
163 | // new MochiKit.Visual.ScrollTo('toolbar', {sync:true}), | ||
164 | MochiKit.Visual.appear ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true}) | ||
165 | ], {duration:1, sync:true}), | ||
166 | MochiKit.Visual.fade(this.getElement('cardList'), {duration:0, sync:true}) | ||
167 | ], {}) | ||
168 | |||
169 | MochiKit.DOM.getElement('pageTitle').innerHTML = someData['title']; | ||
170 | |||
171 | return true; | ||
172 | }, | ||
173 | |||
174 | //------------------------------------------------------------------------- | ||
175 | |||
176 | 'showCardDetails': function (someData) { | ||
177 | return this.cardDetail().showCardDetails(someData); | ||
178 | }, | ||
179 | |||
180 | //========================================================================= | ||
181 | |||
182 | 'backButtonClickHandler': function (anEvent) { | ||
183 | varoffset; | ||
184 | |||
185 | anEvent.preventDefault(); | ||
186 | |||
187 | MochiKit.DOM.getElement('pageTitle').innerHTML = "cards"; | ||
188 | |||
189 | offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480); | ||
190 | MochiKit.Style.setElementPosition(this.getElement('cardList'), {x:-offset}); | ||
191 | MochiKit.DOM.showElement(this.getElement('cardList')); | ||
192 | |||
193 | new MochiKit.Visual.Parallel([ | ||
194 | new MochiKit.Visual.Move(this.getElement('cardList'), {x:offset, y:0, mode:'relative',transition:MochiKit.Visual.Transitions.linear, sync:true}), | ||
195 | new MochiKit.Visual.Move(this.getElement('cardDetail'), {x:offset, y:0, mode:'relative',transition:MochiKit.Visual.Transitions.linear, sync:true}), | ||
196 | MochiKit.Visual.fade (this.getElement('cardDetail'), { transition:MochiKit.Visual.Transitions.linear, sync:true}), | ||
197 | MochiKit.Visual.fade ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true}) | ||
198 | ], {duration:1, afterFinish:MochiKit.Base.method(this, 'removeCardDetail')}) | ||
199 | |||
200 | }, | ||
201 | |||
202 | //========================================================================= | ||
203 | __syntaxFix__: "syntax fix" | ||
204 | }); | ||