mirror of
http://git.whoc.org.uk/git/password-manager.git
synced 2025-10-30 02:47:36 +01:00
First version of the newly restructured repository
This commit is contained in:
166
frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardDetail.js
Normal file
166
frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardDetail.js
Normal file
@@ -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"
|
||||
});
|
||||
204
frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardList.js
Normal file
204
frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardList.js
Normal file
@@ -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"
|
||||
});
|
||||
181
frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js
Normal file
181
frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js
Normal file
@@ -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"
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user