Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js | 142 |
1 files changed, 84 insertions, 58 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js index 3aeac0c..da864eb 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js @@ -46,3 +46,4 @@ Clipperz.PM.UI.Mobile.Components.LoginForm = function(args) { -Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI.Common.Components.BaseComponent, { +//Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI.Common.Components.BaseComponent, { +Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI.Mobile.Components.BaseComponent, { @@ -113,8 +114,8 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. - if (aValue == null) { - MochiKit.Style.hideElement(this.getElement('credentialsMessage')); - } else { - this.getElement('message').innerHTML = aValue; - MochiKit.Style.showElement(this.getElement('credentialsMessage')); - } +// if (aValue == null) { +// MochiKit.Style.hideElement(this.getElement('credentialsMessage')); +// } else { +// this.getElement('message').innerHTML = aValue; +// MochiKit.Style.showElement(this.getElement('credentialsMessage')); +// } }, @@ -123,3 +124,3 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. this._setMessage(aValue); - MochiKit.DOM.removeElementClass(this.getElement('credentialsMessage'), 'error'); +// MochiKit.DOM.removeElementClass(this.getElement('credentialsMessage'), 'error'); }, @@ -128,3 +129,3 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. this._setMessage(aValue); - MochiKit.DOM.addElementClass(this.getElement('credentialsMessage'), 'error'); +// MochiKit.DOM.addElementClass(this.getElement('credentialsMessage'), 'error'); }, @@ -138,4 +139,21 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. + 'show': function (args) { + this.updateWithArgs(args); + + if (this.mode() == 'PIN') { + this.setPin(''); + this.getElement('PIN').focus(); + } else if (this.mode() == 'CREDENTIALS') { + if (this.getElement('usernameField').value.length == 0) { + this.getElement('usernameField').focus(); + } else { + this.getElement('passphraseField').focus(); + this.getElement('passphraseField').select(); + } + } + }, + 'showErrors': function (args) { if (args['previousFailedAttempt'] == 'LOGIN') { + $(this.getAnchor('credentialsSubmitButton')).button('enable'); this.setErrorMessage("Wrong credentials"); @@ -153,29 +171,6 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. 'updateWithArgs': function (args) { - this.renderIfNeeded(); + this.renderOnlyOnce(); this.setCallbacks(args); this.showErrors(args); - this.updateRendering(); - }, - - 'showPinLogin': function (args) { - this.setPin(''); - this.setMode('PIN'); - this.updateWithArgs(args); - -// $(this.getAnchor('PIN')).focus(); - this.getElement('PIN').focus(); - }, - - 'showCredentialsLogin': function (args) { - this.setMode('CREDENTIALS'); - this.updateWithArgs(args); - - if (this.getElement('usernameField').value.length == 0) { -// $(this.getAnchor('usernameField')).focus(); - this.getElement('usernameField').focus(); - } else { -// $(this.getAnchor('passphraseField')).focus(); - this.getElement('passphraseField').focus(); - this.getElement('passphraseField').select(); - } +// this.updateRendering(); }, @@ -184,3 +179,3 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. - 'renderIfNeeded': function () { + 'renderOnlyOnce': function () { if (this.isFullyRendered() == false) { @@ -188,5 +183,5 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. }; - this.updateRendering(); +// this.updateRendering(); }, - +/* 'updateRendering': function () { @@ -198,3 +193,4 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. if (this.mode() == 'CREDENTIALS') { - selectedPanel = this.getElement('credentials') + selectedPanel = this.getElement('credentials'); + $(this.getAnchor('credentialsSubmitButton')).button('enable'); } else if (this.mode() == 'PIN') { @@ -205,14 +201,15 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. } - MochiKit.Style.showElement(selectedPanel); + MochiKit.Style.showElement(selectedPanel); MochiKit.Style.hideElement(this.getElement('validating')); }, - - 'renderSelf': function() { +*/ +/* + '_renderSelf': function() { var selectedPanel; this.append(this.element(), {tag:'div', id:'login', children:[ - {tag:'div', cls:'toolbar', children:[ - {tag:'h1', html:"clipperz"} + {tag:'div', cls:'toolbar text-center', children:[ + {tag:'h1', cls:'clipperz', html:"clipperz"} ]}, - {tag:'div', cls:'scroll', children:[ + {tag:'div', cls:'', children:[ //================================================================== @@ -225,3 +222,3 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. {tag:'div', cls:'pin', id:this.getId('pin'), children:[ - {tag:'form', cls:'scroll', id:this.getId('pinForm'), children:[ + {tag:'form', cls:'', id:this.getId('pinForm'), children:[ {tag:'ul', cls:'edit rounded', children:[ @@ -234,10 +231,11 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. {tag:'div', cls:'credentials', id:this.getId('credentials'), children:[ - {tag:'form', cls:'scroll', id:this.getId('credentialsForm'), children:[ - {tag:'ul', cls:'edit rounded', children:[ - {tag:'li', children:[{tag:'input', type:'email', name:'name', /*value:'joe',*/ placeholder:"username", id:this.getId('usernameField') }]}, - {tag:'li', children:[{tag:'input', type:'password', name:'passphrase', /*value:'clipperz',*/ placeholder:"passphrase", id:this.getId('passphraseField') }]} + {tag:'form', cls:'text-center', id:this.getId('credentialsForm'), children:[ + {tag:'fieldset', children:[ +// {tag:'legend', html:"Legend"}, + {tag:'input', type:'email', name:'name', /*value:'joe',* / placeholder:"username", id:this.getId('usernameField') }, +// {tag:'span', cls:'help-block', html:"Example of help text here"}, + {tag:'input', type:'password', name:'passphrase', /*value:'clipperz',* / placeholder:"passphrase", id:this.getId('passphraseField') }, ]}, - {tag:'a', href:'#', cls:'greenButton', id:this.getId('credentialsSubmitButton'), html:"Login"} -// {tag:'input', type:'submit', cls:'greenButton', id:this.getId('credentialsSubmitButton'), value:"Login"} + {tag:'button', cls:'btn btn-primary btn-large', type:'submit', id:this.getId('credentialsSubmitButton'), html:"Login"} ]} @@ -282,2 +280,27 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. }, +*/ + 'renderSelf': function() { + if (this.isFullyRendered() == false) { + this.append(this.element(), // [ +// {tag:'div', 'data-role':'header', children:[ +// {tag:'h1', html:'clipperz'} +// ]}, +// {tag:'div', 'data-role':'content', children:[ + {tag:'form', id:this.getId('credentialsForm'), children:[ + {tag:'div', 'data-role':'fieldcontain', cls:'ui-hide-label', children:[ + {tag:'label', 'for':'name', cls:'ui-input-text', html:"username"}, + {tag:'input', type:'email', name:'name', /*value:'joe',*/ placeholder:"username", id:this.getId('usernameField') }, + {tag:'label', 'for':'passphrase', cls:'ui-input-text', html:"passphrase"}, + {tag:'input', type:'password', name:'passphrase', /*value:'clipperz',*/ placeholder:"passphrase", id:this.getId('passphraseField') } + ]}, + {tag:'button', type:'submit', id:this.getId('credentialsSubmitButton'), html:"login"} + ]} +// ]} +// ] + ); + + MochiKit.Signal.connect(this.getElement('credentialsForm'), 'onsubmit', this, 'submitCredentialsHandler'); + MochiKit.Signal.connect(this.getElement('credentialsSubmitButton'), 'onclick', this, 'submitCredentialsHandler'); + } + }, @@ -290,4 +313,4 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. pin = this.getElement('PIN').value; -// $(this.getAnchor('PIN')).blur(); - this.getElement('PIN').blur(); + $(this.getAnchor('PIN')).blur(); +// this.getElement('PIN').blur(); @@ -300,3 +323,8 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. - this.setMessage(null); + anEvent.preventDefault(); + +// this.setMessage(null); + $(this.getAnchor('usernameField')).blur(); + $(this.getAnchor('passphraseField')).blur(); + $(this.getAnchor('credentialsSubmitButton')).button('disable'); @@ -305,4 +333,2 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. credentials['passphrase'] = this.getElement('passphraseField').value; -// $(this.getAnchor('passphraseField')).blur(); - this.getElement('passphraseField').blur(); @@ -320,4 +346,4 @@ Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI. - MochiKit.Style.hideElement(this.getElement('credentialsBody')); - MochiKit.Style.showElement(this.getElement('validating')); +// MochiKit.Style.hideElement(this.getElement('credentialsBody')); +// MochiKit.Style.showElement(this.getElement('validating')); |