author | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2011-10-02 23:56:18 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2011-10-02 23:56:18 (UTC) |
commit | ef68436ac04da078ffdcacd7e1f785473a303d45 (patch) (side-by-side diff) | |
tree | c403752d66a2c4775f00affd4fa8431b29c5b68c /frontend/gamma/js/Clipperz/PM/UI/iPhone | |
parent | 597ecfbc0249d83e1b856cbd558340c01237a360 (diff) | |
download | clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.zip clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.gz clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.bz2 |
First version of the newly restructured repository
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/iPhone') (more/less context) (show whitespace changes)
4 files changed, 923 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardDetail.js b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardDetail.js new file mode 100644 index 0000000..23fd236 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardDetail.js @@ -0,0 +1,166 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library is free software: you can redistribute + it and/or modify it under the terms of the GNU Affero General Public + License as published by the Free Software Foundation, either version + 3 of the License, or (at your option) any later version. + +* Javascript Crypto Library is distributed in the hope that it will + be useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + +* You should have received a copy of the GNU Affero General Public + License along with Javascript Crypto Library. If not, see + <http://www.gnu.org/licenses/>. + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.iPhone.Components'); + +Clipperz.PM.UI.iPhone.Components.CardDetail = function(args) { + args = args || {}; + + Clipperz.PM.UI.iPhone.Components.CardDetail.superclass.constructor.apply(this, arguments); + + this._cardReference = null; + + return this; +} + +//============================================================================= + +Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardDetail, Clipperz.PM.UI.Common.Components.BaseComponent, { + + //------------------------------------------------------------------------- + + 'toString': function () { + return "Clipperz.PM.UI.iPhone.Components.CardDetail component"; + }, + + //------------------------------------------------------------------------- + + 'cardReference': function () { + return this._cardReference; + }, + + 'setCardReference': function (aValue) { + this._cardReference = aValue; + }, + + //------------------------------------------------------------------------- + + 'renderSelf': function(/*aContainer, aPosition*/) { + this.append(this.element(), [ + {tag:'div', cls:'cardDetail', id:this.getId('cardDetail'), children:[ + {tag:'div', id:this.getId('progressBar')} //, +// {tag:'h1', cls:'loading', html:"loading"} + ]} + ]); + + this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':this.getElement('progressBar')})); + MochiKit.Signal.signal(Clipperz.PM.UI.Common.Controllers.ProgressBarController.defaultController, 'updateProgress', 0); + }, + + //========================================================================= + + 'showCardDetails': function (someData) { + this.element().innerHTML = ''; + this.append(this.element(), [ + {tag:'fieldset', id:this.getId('fields'), children:MochiKit.Base.map(function (aFieldData) { + return {tag:'div', cls:'row', children:[ + {tag:'label', html:aFieldData['label']}, +// {tag:'span', cls:('fieldValue ' + (aFieldData['isHidden'] ? 'password' : 'text')), html:aFieldData['value']} + {tag:'div', cls:('fieldValue ' + (aFieldData['isHidden'] ? 'password' : 'text')), children:[ + {tag:'div', children:[{tag:'p', html:aFieldData['value']}]} + ]} +// {tag:'input', type:'text', cls:('fieldValue ' + (aFieldData['isHidden'] ? 'password' : 'text')), value:aFieldData['value'], disabled:true} + + ]} + }, someData['fields'])} + ]); + + MochiKit.Iter.forEach(MochiKit.Selector.findChildElements(this.element(), ['span.password']), MochiKit.Base.bind(function (aPasswordElement) { + MochiKit.Signal.connect(aPasswordElement, 'onclick', function (anEvent) { alert(MochiKit.DOM.scrapeText(anEvent.src())); }) + }, this)); + + if (someData['directLogins'].length > 0) { + this.append(this.element(), [ + {tag:'h2', html:"Direct logins"}, + {tag:'fieldset', id:this.getId('directLogins'), children:MochiKit.Base.map(function (aDirectLoginData) { + return {tag:'div', cls:'row', id:('directLogin_' + aDirectLoginData['_reference']), children:[ + {tag:'img', cls:'favicon', src:aDirectLoginData['favicon']}, +// {tag:'input', cls:'directLogin', disabled:'disabled', type:'text', name:aDirectLoginData['label'], value:aDirectLoginData['label']} + {tag:'span', cls:'directLogin', html:aDirectLoginData['label']} + ]} + }, someData['directLogins'])} + ]); + + MochiKit.Base.map(MochiKit.Base.bind(function (aRowNode) { + MochiKit.Signal.connect(aRowNode, 'onclick', this, 'directLoginClickHandler'); + }, this), + MochiKit.Selector.findChildElements(this.getElement('directLogins'), ['div.row']) + ) + }; + + if (someData['notes'] != '') { + this.append(this.element(), [ + {tag:'h2', html:"Notes"}, + {tag:'fieldset', id:this.getId('fieldset'), children:[ + {tag:'div', cls:'row notes', children:[ + {tag:'span', html:someData['notes']} + ]} + ]} + ]); + }; + + return true; + }, + + //------------------------------------------------------------------------- +/* + 'toggleClickHandler': function (anEvent) { + var nextState; + var fieldValue; + +//console.log("TOGGLE"); + anEvent.preventDefault; + fieldValue = MochiKit.Selector.findChildElements(anEvent.src().parentNode.parentNode, ['span.password'])[0]; + + nextState = (MochiKit.DOM.getNodeAttribute(anEvent.src(), 'toggled') != 'true'); + if (nextState) { + MochiKit.DOM.removeElementClass(fieldValue, 'clear'); + } else { + MochiKit.DOM.addElementClass(fieldValue, 'clear'); + } + + MochiKit.DOM.setNodeAttribute(anEvent.src(), 'toggled', nextState); + }, +*/ + //========================================================================= + + 'directLoginClickHandler': function (anEvent) { + anEvent.preventDefault(); + + if (/(directLogin_)/.test(anEvent.src().id)) { + var directLoginReference; + + directLoginReference = anEvent.src().id.match(/(directLogin_)(.*)/)[2]; + MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'selectedDirectLogin', {cardReference:this.cardReference(), directLoginReference:directLoginReference}); + } + }, + + //========================================================================= + + __syntaxFix__: "syntax fix" +}); 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 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library is free software: you can redistribute + it and/or modify it under the terms of the GNU Affero General Public + License as published by the Free Software Foundation, either version + 3 of the License, or (at your option) any later version. + +* Javascript Crypto Library is distributed in the hope that it will + be useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + +* You should have received a copy of the GNU Affero General Public + License along with Javascript Crypto Library. If not, see + <http://www.gnu.org/licenses/>. + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.iPhone.Components'); + +Clipperz.PM.UI.iPhone.Components.CardList = function(args) { + args = args || {}; + + Clipperz.PM.UI.iPhone.Components.CardList.superclass.constructor.apply(this, arguments); + + this._cardDetail = null; + + return this; +} + +//============================================================================= + +Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardList, Clipperz.PM.UI.Common.Components.BaseComponent, { + + //------------------------------------------------------------------------- + + 'toString': function () { + return "Clipperz.PM.UI.iPhone.Components.CardList component"; + }, + + //------------------------------------------------------------------------- + + 'renderSelf': function(/*aContainer, aPosition*/) { + this.append(this.element(), [ + {tag:'div', cls:'toolbar', id:'toolbar', children:[ + {tag:'h1', id:'pageTitle', html:"cards"}, + {tag:'a', id:'backButton', cls:'button', href:'#', html:"cards"} + ]}, + {tag:'div', cls:'cardList', id:this.getId('cardList'), children:[ + {tag:'form', title:'search', cls:'panel cardListSearchForm', id:this.getId('cardListSearchForm'), children:[ + {tag:'input', type:'search', name:'search', value:"", placeholder:"search", id:this.getId('searchField')} + ]}, + {tag:'ul', cls:'panel cardListPanel', id:this.getId('cardListPanel'), children:[]} + ]}, + {tag:'div', cls:'panel cardDetailPanel', id:this.getId('cardDetail')} + ]); + + MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onsubmit', this, 'searchHandler'); + MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeydown', this, 'searchHandler'); + MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeyup', this, 'searchHandler'); + + MochiKit.Signal.connect(this.getElement('cardListPanel'), 'onclick', this, 'cardListClickHandler'); + MochiKit.Signal.connect('backButton', 'onclick', this, 'backButtonClickHandler'); + + MochiKit.Style.hideElement('backButton'); + MochiKit.Style.hideElement(this.getElement('cardDetail')); + }, + + //------------------------------------------------------------------------- + + 'searchHandler': function (anEvent) { + if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ENTER')) { // RETURN + anEvent.preventDefault(); + } else { + if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ESCAPE')) { + anEvent.target().value = ""; + } + + if (anEvent.type() == 'keyup') { + MochiKit.Signal.signal(this, 'searchEvent', anEvent.target().value); + } + } + }, + + //------------------------------------------------------------------------- + + 'update': function (someObjects) { + var cardListPanel; + var i,c; + + cardListPanel = this.getElement('cardListPanel'); + cardListPanel.innerHTML = ''; + + c = someObjects.length; + + for (i=0; i<c; i++) { + this.append(cardListPanel, {tag:'li', cls:'cardListItem', id:('cardListItem_' + someObjects[i]['_reference']), children:[ + {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=')}, + {tag:'a', id:('cardListReference_' + someObjects[i]['_reference']), href:'#', html:someObjects[i]['label']} + ]}) + + MochiKit.Signal.connect('cardListItem_' + someObjects[i]['_reference'], 'onclick', this, 'cardListClickHandler'); + } + + }, + + 'cardListClickHandler': function (anEvent) { + anEvent.preventDefault(); + + if (/(cardListReference_|cardListItem_)/.test(anEvent.target().id)) { + var cardListReference; + + cardListReference = anEvent.target().id.match(/(cardListReference_|cardListItem_)(.*)/)[2]; +//console.log("Showing detail for card named", cardListReference); + MochiKit.Signal.signal(this, 'selectedCard', cardListReference); + } + }, + + //========================================================================= + + 'cardDetail': function (someData) { + if (this._cardDetail == null) { + this._cardDetail = new Clipperz.PM.UI.iPhone.Components.CardDetail({element:this.getElement('cardDetail')}); + } + + return this._cardDetail; + }, + + //------------------------------------------------------------------------- + + 'removeCardDetail': function () { + if (this._cardDetail != null) { + this._cardDetail.remove(); + this._cardDetail = null; + } + }, + + //========================================================================= + + 'showCard': function (someData) { + var deferredResult; + var offset; + + offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480); + this.cardDetail().render(); + this.cardDetail().setCardReference(someData['_reference']); + MochiKit.Style.setElementPosition(this.cardDetail().element(), {x:offset}); + new MochiKit.Visual.Sequence([ +// new MochiKit.Visual.Move(this.cardDetail().element(), {x:offset, y:45, mode:'absolute', duration:0, sync:true}), + new MochiKit.Visual.Parallel([ + new MochiKit.Visual.Move(this.getElement('cardList'), {x:-offset, y:0, mode:'relative', transition:MochiKit.Visual.Transitions.linear, sync:true}), + new MochiKit.Visual.Move(this.getElement('cardDetail'), {x:0, y:45, mode:'absolute', transition:MochiKit.Visual.Transitions.linear, sync:true}), +// new MochiKit.Visual.ScrollTo('toolbar', {sync:true}), + MochiKit.Visual.appear ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true}) + ], {duration:1, sync:true}), + MochiKit.Visual.fade(this.getElement('cardList'), {duration:0, sync:true}) + ], {}) + + MochiKit.DOM.getElement('pageTitle').innerHTML = someData['title']; + + return true; + }, + + //------------------------------------------------------------------------- + + 'showCardDetails': function (someData) { + return this.cardDetail().showCardDetails(someData); + }, + + //========================================================================= + + 'backButtonClickHandler': function (anEvent) { + var offset; + + anEvent.preventDefault(); + + MochiKit.DOM.getElement('pageTitle').innerHTML = "cards"; + + offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480); + MochiKit.Style.setElementPosition(this.getElement('cardList'), {x:-offset}); + MochiKit.DOM.showElement(this.getElement('cardList')); + + new MochiKit.Visual.Parallel([ + new MochiKit.Visual.Move(this.getElement('cardList'), {x:offset, y:0, mode:'relative', transition:MochiKit.Visual.Transitions.linear, sync:true}), + new MochiKit.Visual.Move(this.getElement('cardDetail'), {x:offset, y:0, mode:'relative', transition:MochiKit.Visual.Transitions.linear, sync:true}), + MochiKit.Visual.fade (this.getElement('cardDetail'), { transition:MochiKit.Visual.Transitions.linear, sync:true}), + MochiKit.Visual.fade ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true}) + ], {duration:1, afterFinish:MochiKit.Base.method(this, 'removeCardDetail')}) + + }, + + //========================================================================= + __syntaxFix__: "syntax fix" +}); diff --git a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js new file mode 100644 index 0000000..eec83b0 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js @@ -0,0 +1,181 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library is free software: you can redistribute + it and/or modify it under the terms of the GNU Affero General Public + License as published by the Free Software Foundation, either version + 3 of the License, or (at your option) any later version. + +* Javascript Crypto Library is distributed in the hope that it will + be useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + +* You should have received a copy of the GNU Affero General Public + License along with Javascript Crypto Library. If not, see + <http://www.gnu.org/licenses/>. + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.iPhone.Components'); + +Clipperz.PM.UI.iPhone.Components.LoginForm = function(args) { + args = args || {}; + + Clipperz.PM.UI.iPhone.Components.LoginForm.superclass.constructor.apply(this, arguments); + + return this; +} + +//============================================================================= + +Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.LoginForm, Clipperz.PM.UI.Common.Components.BaseComponent, { + + //------------------------------------------------------------------------- + + 'toString': function () { + return "Clipperz.PM.UI.iPhone.Components.LoginForm component"; + }, + + //------------------------------------------------------------------------- + + 'focusOnUsername': function () { + this.getElement('username').focus(); + }, + + //------------------------------------------------------------------------- + + 'username': function () { + return this.getElement('username').value; + }, + + 'passphrase': function () { + return this.getElement('passphrase').value; + }, + + //------------------------------------------------------------------------- + + 'renderSelf': function(/*aContainer, aPosition*/) { + this.append(this.element(), [ + {tag:'div', cls:'toolbar iPhoneClipperzToolbar', children:[ + {tag:'h1', id:'pageTitle', html:'Clipperz'}, + {tag:'a', id:'backButton', cls:'button', href:'#', html:"back"} + ]}, + {tag:'form', title:'Theaters', cls:'panel toolbarlessPanel loginForm', id:this.getId('loginFormPanel'), children:[ + {tag:'fieldset', id:this.getId('fieldset'), children:[ + {tag:'div', cls:'row', children:[ + {tag:'label', html:"username"}, + {tag:'input', type:'text', name:'username', value:"", autocorrect:'off', autocapitalize:'off', id:this.getId('username')} + ]}, + {tag:'div', cls:'row', children:[ + {tag:'label', html:"passphrase"}, + {tag:'input', type:'password', name:'passphrase', value:"", id:this.getId('passphrase')} + ]} + ]}, + {tag:'a', cls:'whiteButton', type:'submit', href:'#', html:"Login", id:this.getId('submit')} + ]}, + {tag:'div', cls:'panel toolbarlessPanel loginProgressPanel', id:this.getId('loginProgressPanel'), children:[ + {tag:'div', id:this.getId('progressBar')} //, +// {tag:'a', cls:'whiteButton', type:'submit', href:'#', html:"Cancel", id:this.getId('cancel')} + ]}, + {tag:'div', cls:'panel loginErrorPanel', id:this.getId('loginErrorPanel'), children:[ + {tag:'div', cls:'errorMessage', id:this.getId('errorMessageBox'), children:[ + {tag:'h2', id:this.getId('errorMessage'), html:"Login failed"} + ]} + ]} + ]); + + MochiKit.Signal.connect(this.getElement('submit'), 'onclick', this, 'submitHandler'); + MochiKit.Signal.connect(this.getElement('loginFormPanel'), 'onsubmit', this, 'submitHandler'); + +// MochiKit.Signal.connect(this.getElement('cancel'), 'onclick', this, 'cancelHandler'); + MochiKit.Signal.connect('backButton', 'onclick', this, 'backHandler'); + + this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':this.getElement('progressBar')})); + +// MochiKit.Style.hideElement(this.getElement('errorMessage')); + + this.showLoginForm(); +// MochiKit.Async.callLater(0.2, MochiKit.Base.method(this, 'focusOnUsername')); + }, + + //------------------------------------------------------------------------- + + 'showLoginForm': function () { + MochiKit.Style.showElement(this.getElement('loginFormPanel')); + MochiKit.Style.hideElement(this.getElement('loginProgressPanel')); + MochiKit.Style.hideElement(this.getElement('loginErrorPanel')); + MochiKit.Style.hideElement('backButton'); + }, + + 'slideInLoginForm': function () { + var offset; + + offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480); + + MochiKit.Style.showElement(this.getElement('loginFormPanel')); + MochiKit.Style.setElementPosition(this.getElement('loginFormPanel'), {x:-offset, y:0}); + + new MochiKit.Visual.Sequence([ + new MochiKit.Visual.Parallel([ + new MochiKit.Visual.Move(this.getElement('loginErrorPanel'), {x:offset, y:0, mode:'relative', transition:MochiKit.Visual.Transitions.linear, sync:true}), + new MochiKit.Visual.Move(this.getElement('loginFormPanel'), {x:0, y:0, mode:'absolute', transition:MochiKit.Visual.Transitions.linear, sync:true}), + MochiKit.Visual.fade ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true}) + ], {duration:0.5, sync:true}), + MochiKit.Visual.fade(this.getElement('loginErrorPanel'), {duration:0, sync:true}) + ], {}) + }, + + 'showLoginProgress': function () { + MochiKit.Style.hideElement(this.getElement('loginFormPanel')); + MochiKit.Style.showElement(this.getElement('loginProgressPanel')); + }, + + 'showLoginError': function (anError) { + this.getElement('errorMessage').innerHTML = "Login error"; + + MochiKit.Style.showElement('backButton'); + MochiKit.Style.hideElement(this.getElement('loginProgressPanel')); + MochiKit.Style.showElement(this.getElement('loginErrorPanel')); + MochiKit.Style.setElementPosition(this.getElement('loginErrorPanel'), {x:0, y:45}); + }, + + //------------------------------------------------------------------------- +/* + 'disableCancelButton': function () { + MochiKit.DOM.hideElement(this.getElement('cancel')); + }, +*/ + //------------------------------------------------------------------------- + + 'submitHandler': function (anEvent) { + anEvent.preventDefault(); + + MochiKit.Signal.signal(this, 'doLogin', {'username':this.username(), 'passphrase':this.passphrase()}); + }, + + 'cancelHandler': function (anEvent) { + anEvent.preventDefault(); + +//console.log("CANCEL"); + }, + + 'backHandler': function (anEvent) { + anEvent.preventDefault(); + + this.slideInLoginForm(); + }, + + //------------------------------------------------------------------------- + + __syntaxFix__: "syntax fix" +}); diff --git a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Controllers/MainController.js b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Controllers/MainController.js new file mode 100644 index 0000000..b43d877 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Controllers/MainController.js @@ -0,0 +1,372 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library is free software: you can redistribute + it and/or modify it under the terms of the GNU Affero General Public + License as published by the Free Software Foundation, either version + 3 of the License, or (at your option) any later version. + +* Javascript Crypto Library is distributed in the hope that it will + be useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + +* You should have received a copy of the GNU Affero General Public + License along with Javascript Crypto Library. If not, see + <http://www.gnu.org/licenses/>. + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.iPhone.Controllers'); + +// Some parts of this controller have been derived from the iUI library. + +Clipperz.PM.UI.iPhone.Controllers.MainController = function() { + this._loginForm = null; + this._cardList = null; + this._cachedValues = null; + this._user = null; + + if (typeof window.onorientationchange == 'object') { + MochiKit.Signal.connect(window, 'onorientationchange', this, 'orientationChangeHandler'); + MochiKit.Async.callLater(0, MochiKit.Base.method(this, 'orientationChangeHandler')); + } else { + this.setOrientation('portrait'); +// this.setOrientation('landscape'); + } + + this.addMetaTag('viewport', 'width=devicewidth; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;'); + this.addMetaTag('apple-mobile-web-app-capable', 'yes'); + this.addMetaTag('apple-mobile-web-app-status-bar-style', 'black'); + + this.addLinkTag('apple-touch-icon', 'data:image/png;charset=utf-8;base64,iVBORw0KGgoAAAANSUhEUgAAAF8AAABfCAYAAACOTBv1AAA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GxojmbA8R7T/ZvTKF3W7rsHwDB/SL+jkDIqpbxH/qdMrX+f5U6JIfRbrkR5Eu+VGkS34U6ZIfRbrkR5Eu+VGkS34U6ZIfRbrkR5H/Bx8z6HmTXnicAAAAAElFTkSuQmCCCg=='); +// this.addLinkTag('apple-touch-startup-image', 'default.png'); + +// if (!window.navigator.standalone) // not running as an installed app + + MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'selectedDirectLogin', this, 'selectedDirectLoginHandler'); + + MochiKit.DOM.addElementClass(document.body, 'iPhone'); + return this; +} + +MochiKit.Base.update(Clipperz.PM.UI.iPhone.Controllers.MainController.prototype, { + + 'toString': function () { + return "Clipperz.PM.UI.iPhone.Controllers.MainController"; + }, + + //========================================================================= + + 'user': function () { + return this._user; + }, + + 'setUser': function (aValue) { + this._user = aValue; + }, + + //========================================================================= + + 'loginForm': function() { + if (this._loginForm == null) { + MochiKit.DOM.removeElement('mainDiv'); + this._loginForm = new Clipperz.PM.UI.iPhone.Components.LoginForm({element:MochiKit.DOM.currentDocument().body}); + MochiKit.Signal.connect(this._loginForm, 'doLogin', this, 'doLoginHandler') + } + + return this._loginForm; + }, + + 'removeLoginForm': function () { + if (this._loginForm != null) { + this._loginForm.remove(); + this._loginForm = null; + } + }, + + //----------------------------------------------------------------------------- + + 'cardList': function () { + if (this._cardList == null) { + this._cardList = new Clipperz.PM.UI.iPhone.Components.CardList({element:MochiKit.DOM.currentDocument().body}); + MochiKit.Signal.connect(this._cardList, 'searchEvent', this, 'searchEventHandler') + MochiKit.Signal.connect(this._cardList, 'selectedCard', this, 'selecetedCardHandler') + } + + return this._cardList; + }, + + //========================================================================= + + 'currentWidth': function () { + return this._currentWidth; + }, + + 'setCurrentWidth': function (aValue) { + this._currentWidth = aValue; + }, + + //========================================================================= + + 'orientationChangeHandler': function () { + switch(window.orientation) { + case 0: + this.setOrientation('portrait'); + break; + case 90: + case -90: + this.setOrientation('landscape'); + break; + } + }, + + //------------------------------------------------------------------------- + + 'setOrientation': function (anOrientation) { + document.body.setAttribute('orientation', anOrientation); + setTimeout(scrollTo, 100, 0, 1); + }, + + //------------------------------------------------------------------------- + + 'slidePages': function (fromPage, toPage, backwards) { + var axis; + var slideDone; + + slideDone = function () { + // console.log("slideDone"); + if (!hasClass(toPage, "dialog")) { + fromPage.removeAttribute("selected"); + } + checkTimer = setInterval(checkOrientAndLocation, 300); + setTimeout(updatePage, 0, toPage, fromPage); + fromPage.removeEventListener('webkitTransitionEnd', slideDone, false); + } + + axis = (backwards ? fromPage : toPage).getAttribute("axis"); + + clearInterval(checkTimer); + + if (canDoSlideAnim() && axis != 'y') { + slide2(fromPage, toPage, backwards, slideDone); + } else { + slide1(fromPage, toPage, backwards, axis, slideDone); + } + }, + + //------------------------------------------------------------------------- + + 'getCachedValues': function () { + var deferredResult; + + if (this._cachedObjects != null) { + deferredResult = MochiKit.Async.succeed(this._cachedObjects); + } else { + deferredResult = new Clipperz.Async.Deferred("MainController.getCachedValues", {trace:false}); + deferredResult.addMethod(this.user(), 'getRecords'); + deferredResult.addCallback(MochiKit.Base.map, Clipperz.Async.collectResults("MainController.getCachedValues - collectResults", { + '_rowObject': MochiKit.Async.succeed, + '_reference': MochiKit.Base.methodcaller('reference'), + 'label': MochiKit.Base.methodcaller('label'), + 'favicon': MochiKit.Base.methodcaller('favicon'), + '_searchableContent': MochiKit.Base.methodcaller('searchableContent') + }, {trace:false})); + deferredResult.addCallback(Clipperz.Async.collectAll); + deferredResult.addCallback(MochiKit.Base.bind(function (someRows) { + this._cachedObjects = someRows; + return this._cachedObjects; + }, this)); + deferredResult.callback(); + } + + return deferredResult; + }, + //========================================================================= + + 'run': function(shouldShowRegistrationForm) { + this.loginForm().render(); + MochiKit.Async.callLater(1, MochiKit.Base.method(this.loginForm(), 'focusOnUsername')); + }, + + //========================================================================= + + 'doLoginHandler': function (someArgs) { + var deferredResult; + var parameters; + var shouldUseOTP; +// var loginProgress; + var user; + var getPassphraseDelegate; + + parameters = someArgs; + shouldUseOTP = (typeof(parameters.passphrase) == 'undefined'); + + getPassphraseDelegate = MochiKit.Base.partial(MochiKit.Async.succeed, parameters.passphrase); + user = new Clipperz.PM.DataModel.User({'username':parameters.username, 'getPassphraseFunction':getPassphraseDelegate}); + + deferredResult = new Clipperz.Async.Deferred("MainController.doLogin", {trace:false}); + deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':4}); + deferredResult.addMethod(this.loginForm(), 'showLoginProgress'); + deferredResult.addCallback(MochiKit.Async.wait, 0.1); + deferredResult.addMethod(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'deferredEntropyCollection'); + deferredResult.addMethod(user, 'login'); + deferredResult.addMethod(this, 'setUser', user); + deferredResult.addMethod(user, 'getRecords'); + deferredResult.addMethod(this, 'removeLoginForm'); + deferredResult.addMethod(this.cardList(), 'render'); + deferredResult.addMethod(this, 'displaySelectedRecords', ''); + deferredResult.addErrback(MochiKit.Base.method(this.loginForm(), 'showLoginError')); + deferredResult.callback(); + + return deferredResult; + }, + + //========================================================================= + + 'searchEventHandler': function (aValue) { +//console.log("searching for ... " + aValue); + return this.displaySelectedRecords(aValue); + }, + + //========================================================================= + + '_displaySelectedRows': function (aFilter, someRows) { + var result; + + result = someRows; + + if (aFilter != null) { + var filter; + var filterRegExp; + + filter = aFilter.replace(/[^A-Za-z0-9]/g, "\\$&"); + filterRegExp = new RegExp(filter, "i"); + result = MochiKit.Base.filter(function (aCachedResult) { return filterRegExp.test(aCachedResult['_searchableContent'])}, result); + } + + + result.sort(MochiKit.Base.partial(function (aKey, aComparator, aObject, bObject) { + return aComparator(aObject[aKey], bObject[aKey]); + }, 'label', Clipperz.Base.caseInsensitiveCompare)); + + this.cardList().update(result); + }, + + //------------------------------------------------------------------------- + + 'displaySelectedRecords': function (aFilter) { + return Clipperz.Async.callbacks("MainController.displaySelectedrows", [ + MochiKit.Base.method(this, 'getCachedValues'), + MochiKit.Base.method(this, '_displaySelectedRows', aFilter) + ], {trace:false}); + }, + + //========================================================================= + + 'selecetedCardHandler': function (aRecordReference) { + var deferredResult; + var recordData; + + recordData = {}; +//console.log("Showing detail for card with reference", aRecordReference); + deferredResult = new Clipperz.Async.Deferred("MainController.selectedCardHandler", {trace:false}); + deferredResult.addMethod(this.user(), 'getRecord', aRecordReference); + deferredResult.collectResults({ + '_reference': MochiKit.Base.methodcaller('reference'), + 'title': MochiKit.Base.methodcaller('label'), + 'favicon': MochiKit.Base.methodcaller('favicon') + }); + deferredResult.addCallback(function (someData) { + MochiKit.Base.update(recordData, someData); + }) + deferredResult.addMethod(this.cardList(), 'showCard', recordData); + + deferredResult.addMethod(this.user(), 'getRecord', aRecordReference); + deferredResult.addMethodcaller('notes'); + deferredResult.addCallback(function (someNotes) { + recordData['notes'] = someNotes; + }) + + deferredResult.addMethod(this.user(), 'getRecord', aRecordReference); + deferredResult.addMethodcaller('getCurrentRecordVersion'); + deferredResult.addMethodcaller('fields'); + deferredResult.addCallback(MochiKit.Base.values); + deferredResult.addCallback(MochiKit.Base.map, Clipperz.Async.collectResults("MainController.selectedCardHandler - fields", { + 'label': MochiKit.Base.methodcaller('label'), + 'value': MochiKit.Base.methodcaller('value'), + 'isHidden': MochiKit.Base.methodcaller('isHidden') + }, {trace:false})); + deferredResult.addCallback(Clipperz.Async.collectAll); + deferredResult.addCallback(function (someData) { + recordData['fields'] = someData; + }); + + deferredResult.addMethod(this.user(), 'getRecord', aRecordReference); + deferredResult.addMethodcaller('directLogins'); + deferredResult.addCallback(MochiKit.Base.values); + deferredResult.addCallback(MochiKit.Base.map, Clipperz.Async.collectResults("MainController.selectedCardHandler - directLogins", { + 'label': MochiKit.Base.methodcaller('label'), + 'favicon': MochiKit.Base.methodcaller('favicon'), + '_reference': MochiKit.Base.methodcaller('reference') + }, {trace:false})); + deferredResult.addCallback(Clipperz.Async.collectAll); + deferredResult.addCallback(function (someData) { + recordData['directLogins'] = someData; + }); + + deferredResult.addMethod(this.cardList(), 'showCardDetails', recordData); + deferredResult.callback(); + + return deferredResult; + }, + + //========================================================================= + + 'selectedDirectLoginHandler': function (someData) { + var deferredResult; + +//console.log("<<< signal - directLogin"); + deferredResult = new Clipperz.Async.Deferred("MainController.selectedDirectLoginHandler", {trace:false}); + deferredResult.addMethod(this.user(), 'getRecord', someData['cardReference']); + deferredResult.addMethodcaller('directLogins'); + deferredResult.addCallback(MochiKit.Base.itemgetter(someData['directLoginReference'])); +// deferredResult.addMethodcaller('runDirectLogin'); + deferredResult.addCallback(Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.openDirectLogin); + deferredResult.callback(); + + return deferredResult; + }, + + //========================================================================= + + 'addMetaTag': function (aName, aContent) { + var metaTag; + + metaTag = document.createElement('meta'); + metaTag.name = aName; + metaTag.content = aContent; + document.getElementsByTagName('head')[0].appendChild(metaTag); + }, + + 'addLinkTag': function (aRel, anHref) { + var linkTag; + + linkTag = document.createElement('link'); + linkTag.rel = aRel; + linkTag.href = anHref; + document.getElementsByTagName('head')[0].appendChild(linkTag); + }, + + //========================================================================= + __syntaxFix__: "syntax fix" +});
\ No newline at end of file |