hedera-web/js/hedera/social-bar.js

74 lines
1.2 KiB
JavaScript
Raw Normal View History

module.exports = new Class
({
Extends: Htk.Widget
,Tag: 'htk-social-bar'
,Properties:
{
conn:
{
type: Db.Connection
,set: function (x)
{
this._conn = x;
}
,get: function ()
{
return this._conn;
}
},
priority:
{
type: Number
,set: function (x)
{
this._priority = x;
}
,get: function ()
{
return this._priority;
}
},
}
,_priority: null
,initialize: function ()
{
this.createElement ('div');
this._node.className = 'htk-social-bar';
}
,_refresh: function ()
{
if (!this._conn || this._priority === null)
return;
var query = 'SELECT title, link, icon FROM social '
+'WHERE priority ORDER BY priority';
this._conn.execQuery (query, this._onQueryDone.bind (this));
}
,_onQueryDone: function (resultSet)
{
Vn.Node.removeChilds (this._node);
var res = resultSet.fetchResult ();
while (res.next ())
{
var a = document.createElement ('a');
a.href = res.get ('link');
a.target = '_blank';
this._node.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);
}
}
});