diff --git a/js/hedera/app.js b/js/hedera/app.js
index 580ddc9d..80637ee2 100644
--- a/js/hedera/app.js
+++ b/js/hedera/app.js
@@ -23,77 +23,15 @@ module.exports = new Class
window.onunload = this._onWindowUnload.bind (this);
Vn.Hash.initialize ();
- this._isGuest = new Vn.HashParam
- ({
- type: Boolean,
- key: 'guest'
- });
- this._isGuest.on ('changed', this._onGuestChange, this);
-
var conn = new Db.Connection ();
this.link ({_conn: conn}, {'error': this._onConnError});
}
,run: function ()
{
- var guest = localStorage.getItem ('hederaGuest');
-
- if (guest)
- localStorage.removeItem ('hederaGuest');
-
- if (localStorage.getItem ('vnToken'))
- {
- this._conn.open (null, null, null,
- this._onAutoLogin.bind (this));
- }
- else if (this._isGuest.value || guest)
- {
- this._guestLogin ();
- }
- else
- {
- var login = this._login = new Login ({conn: this._conn});
- login.on ('login', this._onLogin, this);
- login.show ();
- }
- }
-
- ,_onGuestChange: function ()
- {
- if (this._isGuest.value)
- this._guestLogin ();
- }
-
- ,_guestLogin: function ()
- {
- this._conn.open (
- null,
- null,
- null,
- this._onGuestLogin.bind (this),
- true
- );
- }
-
- ,_onGuestLogin: function (conn, success)
- {
- this._isGuest.value = undefined;
-
- if (success)
- {
- localStorage.setItem ('hederaGuest', true);
- this._onLogin ();
- }
- else
- this.run ();
- }
-
- ,_onAutoLogin: function (success)
- {
- if (!success)
- this.run ();
- else
- this._onLogin ();
+ var login = this._login = new Login ({conn: this._conn});
+ login.on ('login', this._onLogin, this);
+ login.show ();
}
,_onLogin: function ()
@@ -107,8 +45,8 @@ module.exports = new Class
,_onLogout: function (gui)
{
- this._freeGui ();
localStorage.removeItem ('hederaGuest');
+ this._freeGui ();
this.run ();
}
diff --git a/js/hedera/gui.css b/js/hedera/gui.css
index b745fd20..acf1cfd2 100644
--- a/js/hedera/gui.css
+++ b/js/hedera/gui.css
@@ -266,26 +266,15 @@
padding: 0.7em 20%;
}
-/* Links */
+/* Social */
-.vn-gui .links
+.vn-gui .social
{
position: absolute;
bottom: 0;
right: 0;
padding: 0.8em;
}
-.vn-gui .links a
-{
- padding: 0.1em;
- display: block;
- float: left;
- max-width: 2.2em;
-}
-.vn-gui .links img
-{
- height: 1.8em;
-}
/* Body */
diff --git a/js/hedera/gui.xml b/js/hedera/gui.xml
index 16cbf71f..0d97f321 100755
--- a/js/hedera/gui.xml
+++ b/js/hedera/gui.xml
@@ -28,19 +28,8 @@
-
diff --git a/js/hedera/hedera.js b/js/hedera/hedera.js
index 2bac9b3d..0a88c251 100644
--- a/js/hedera/hedera.js
+++ b/js/hedera/hedera.js
@@ -5,6 +5,7 @@ Vn.includeCss ('js/hedera/style.css');
Hedera = module.exports = {
Login : require ('./login')
+ ,SocialBar : require ('./social-bar')
,Gui : require ('./gui')
,Module : require ('./module')
,Form : require ('./form')
diff --git a/js/hedera/login.css b/js/hedera/login.css
index 9ec43ac1..49f0c1c1 100644
--- a/js/hedera/login.css
+++ b/js/hedera/login.css
@@ -196,20 +196,6 @@ hr
{
margin-top: 3em;
}
-.vn-login .social
-{
- text-align: center;
-}
-.vn-login .social a
-{
- display: inline-block;
- margin: 0 .1em;
-}
-.vn-login .social img
-{
- height: 1.8em;
- width: 1.8em;
-}
.vn-login .contact
{
text-align: center;
diff --git a/js/hedera/login.js b/js/hedera/login.js
index 3eef87e3..8b4ed800 100644
--- a/js/hedera/login.js
+++ b/js/hedera/login.js
@@ -13,10 +13,6 @@ module.exports = new Class
,set: function (x)
{
this.link ({_conn: x}, {'loading-changed': this._onConnLoadChange});
- x.execQuery (
- 'SELECT title, link, icon FROM social '
- +'WHERE priority ORDER BY priority',
- this._onSocialQueryDone.bind (this));
}
,get: function ()
{
@@ -27,6 +23,7 @@ module.exports = new Class
,initialize: function (props)
{
+ this.parent (props);
this.builderInitString (Tpl);
var self = this;
@@ -35,8 +32,6 @@ module.exports = new Class
self._onSubmit ();
return false;
};
-
- this.parent (props);
}
,_onConnLoadChange: function (conn, isLoading)
@@ -51,16 +46,103 @@ module.exports = new Class
{
document.body.appendChild (this.node);
- var lastUser = localStorage.getItem ('hederaLastUser');
+ var isGuest = new Vn.HashParam
+ ({
+ type: Boolean,
+ key: 'guest'
+ });
+ this.link ({_isGuest: isGuest}, {'changed': this._onGuestChange});
- if (lastUser)
- this.$('user').value = lastUser;
+ var token = new Vn.HashParam
+ ({
+ type: String,
+ key: 'token'
+ });
+ this.link ({_token: token}, {'changed': this._onTokenChange});
+
+ this._onGuestChange ();
+ this._onTokenChange ();
+
+ if (!this._loginStarted
+ && (localStorage.getItem ('vnToken')
+ || sessionStorage.getItem ('vnToken')))
+ this.login ();
- this._focusUserInput ();
+ if (!this._loginStarted)
+ {
+ var lastUser = localStorage.getItem ('hederaLastUser');
+
+ if (lastUser)
+ this.$('user').value = lastUser;
+
+ this._focusUserInput ();
+ }
+ }
+
+ ,_onTokenChange: function ()
+ {
+ if (!this.loginStarted && this._token.value)
+ {
+ this._conn.token = this._token.value;
+ this.login ();
+ }
+ }
+
+ ,_onGuestChange: function ()
+ {
+ var guest = localStorage.getItem ('hederaGuest');
+
+ if (!this.loginStarted && (this._isGuest.value || guest))
+ {
+ localStorage.setItem ('hederaGuest', true);
+ this.login ();
+ }
+ }
+
+ ,_onSubmit: function ()
+ {
+ this.login (
+ this.$('user').value,
+ this.$('pass').value,
+ this.$('remember').checked
+ );
+ }
+
+ ,login: function (user, pass, remember)
+ {
+ this._loginStarted = true;
+ this._conn.open (user, pass, remember,
+ this._onConnOpen.bind (this));
+ this._disableUi (true);
+ }
+
+ ,_onConnOpen: function (conn, success, error)
+ {
+ this._token.value = undefined;
+ this._isGuest.value = undefined;
+ this._loginStarted = false;
+ this.$('pass').value = '';
+ this._disableUi (false);
+
+ if (success)
+ {
+ var user = this.$('user').value;
+
+ if (user && !localStorage.getItem ('hederaGuest'))
+ localStorage.setItem ('hederaLastUser', user);
+ this.signalEmit ('login');
+ }
+ else
+ {
+ localStorage.removeItem ('hederaGuest');
+ this._focusUserInput ();
+ }
}
,hide: function ()
{
+ this._isGuest.unref ();
+ this._token.unref ();
Vn.Node.remove (this.node);
}
@@ -78,32 +160,6 @@ module.exports = new Class
this.$('submit').disabled = disabled;
}
- ,_onSubmit: function ()
- {
- this._conn.open (
- this.$('user').value,
- this.$('pass').value,
- this.$('remember').checked,
- this._onConnOpen.bind (this)
- );
-
- this._disableUi (true);
- }
-
- ,_onConnOpen: function (conn, success, error)
- {
- this.$('pass').value = '';
- this._disableUi (false);
-
- if (success)
- {
- localStorage.setItem ('hederaLastUser', this.$('user').value);
- this.signalEmit ('login');
- }
- else
- this._focusUserInput ();
- }
-
,onPasswordLost: function ()
{
var user = this.$('user').value;
@@ -122,25 +178,5 @@ module.exports = new Class
else
Htk.Toast.showError (error.message);
}
-
- ,_onSocialQueryDone: function (resultSet)
- {
- var res = resultSet.fetchResult ();
- var social = this.$('social');
-
- while (res.next ())
- {
- var a = document.createElement ('a');
- a.href = res.get ('link');
- a.target = '_blank';
- social.appendChild (a);
-
- var img = document.createElement ('img');
- img.src = 'image/social/'+ res.get ('icon');
- img.alt = res.get ('title');
- img.title = res.get ('title');
- a.appendChild (img);
- }
- }
});
diff --git a/js/hedera/login.xml b/js/hedera/login.xml
index ed3f51c8..93ef0095 100755
--- a/js/hedera/login.xml
+++ b/js/hedera/login.xml
@@ -50,6 +50,7 @@