1
0
Fork 0

Some more view events....

master
Matthieu Lalonde 12 years ago committed by xSmurf
parent b6883d2f45
commit edd00380cf

@ -102,8 +102,10 @@
</div> </div>
<div class="ui-layout-south row-fluid" id="wrapperFooter"> <div class="ui-layout-south row-fluid" id="wrapperFooter">
<div id="wrapperFooterLeft" class="span4"> <div id="wrapperFooterLeft" class="span4 row-fluid">
<button class="btn btn-mini btn-inverse" type="button" data-toggle="side-bar"><i class="icon-chevron-left icon-white"></i></button> <div class="span2">
<button class="btn btn-mini btn-inverse" type="button" data-toggle="side-bar"><i class="icon-chevron-right icon-white"></i></button>
</div>
<button class="btn btn-mini btn-inverse" type="button" data-toggle="button"><i class="icon-random icon-white"></i></button> <button class="btn btn-mini btn-inverse" type="button" data-toggle="button"><i class="icon-random icon-white"></i></button>
<button class="btn btn-mini btn-inverse" type="button" data-toggle="button"><i class="icon-retweet icon-white"></i></button> <button class="btn btn-mini btn-inverse" type="button" data-toggle="button"><i class="icon-retweet icon-white"></i></button>
</div> </div>

@ -382,10 +382,14 @@ div#wrapperPlayer {
div#wrapperFooter, div#wrapperFooter,
table.dataTable tr td, table.dataTable tr td,
table.dataTable tr th { table.dataTable tr th,
div#wrapperSideBar,
div#wrapperPlayer {
-webkit-user-select: none; -webkit-user-select: none;
-ms-user-select: none;
-moz-user-select: none; -moz-user-select: none;
-khtml-user-select: none; -khtml-user-select: none;
user-select: none;
cursor: default; cursor: default;
} }

@ -21,6 +21,8 @@ define([
constructor: function(attributes, options) { constructor: function(attributes, options) {
_.bindAll(this _.bindAll(this
, "setAuth" , "setAuth"
, "setState"
, "getState"
, "init" , "init"
, "deinit" , "deinit"
, "logout" , "logout"
@ -69,10 +71,30 @@ define([
} }
} }
, init: function () { , setState: function (state) {
if (_.isNumber(state)) {
this.trigger("state", this, state);
return this.state = state;
} else if (_.isString(state) && !_.isUndefined(this._states[state])) {
this.trigger("state", this, this._states[state]);
return this.state = this._states[state];
}
return undefined;
}
, getState: function () {
return this.state;
}
, init: function () {
var that = this var that = this
; ;
this.setState("connecting");
console.debug("Fetching content types"); console.debug("Fetching content types");
that.fetchContentTypes(function __fnClientCbFetchContentTypes(contentTypes) { that.fetchContentTypes(function __fnClientCbFetchContentTypes(contentTypes) {
console.debug("Fetching server info"); console.debug("Fetching server info");
@ -94,6 +116,7 @@ define([
//that.fetchArtists(function () { //that.fetchArtists(function () {
//console.debug("Fetching albums of db 1"); //console.debug("Fetching albums of db 1");
//that.fetchAlbums(function () { //that.fetchAlbums(function () {
that.setState("connected");
that.trigger("inited", serverInfo); that.trigger("inited", serverInfo);
//}); //});
//}); //});
@ -157,7 +180,7 @@ define([
uri += prefix + "session-id=" + this.collections.session.id; uri += prefix + "session-id=" + this.collections.session.id;
} }
return this.attributes.protocol + "://" + this.urlHost() + uri; return this.attributes.protocol + "://" + this.urlHost() + uri;
} }
@ -195,11 +218,15 @@ define([
try { try {
xhr.onerror = function () {console.log("Error", arguments, this);}; xhr.onerror = function () {console.log("Error", arguments, this);};
xhr.onabort = function () {console.log("Abort", arguments, this);}; xhr.onabort = function () {console.log("Abort", arguments, this);};
xhr.ontimeout = function () {console.log("Timeout", arguments, this);}; xhr.ontimeout = function () {
that.setState("timedout");
};
xhr.onload = function (e) { xhr.onload = function (e) {
if (this.status === 200) { if (this.status === 200) {
callback(null, this.response); callback(null, this.response);
} else if (this.status === 401) { } else if (this.status === 401) {
that.setState("unauthorized");
that.trigger("unauthorized", [this, e]); that.trigger("unauthorized", [this, e]);
} else { } else {
callback(e.status); callback(e.status);
@ -428,15 +455,16 @@ define([
, password: "" , password: ""
} }
, status: 0 , state: 0
, statusCodes: { , _states: {
disconnected: 0 disconnected: 0
, connecting: 1 , timedout: 1
, timedout: 2 , connecting: 2
, unauthorized: 3 , unauthorized: 3
, connected: 4 , connected: 4
, loaded: 5 , loading: 5
, loaded: 6
} }
, collections: { , collections: {

@ -159,6 +159,10 @@ _
} }
}); });
item.on("client:state", function __fnSideBarViewEventClientState(event) {
that.changeServerItemState($item.find("span > i:first-child"), event);
});
item.client.init(); item.client.init();
$item.find("a.sidebar-list-action").on("click", function (model) { $item.find("a.sidebar-list-action").on("click", function (model) {
@ -177,9 +181,40 @@ _
$item.on("dblclick", function (model) { $item.on("dblclick", function (model) {
return function __fnSideBarViewEventDblClickItem(event) { return function __fnSideBarViewEventDblClickItem(event) {
}; };
}(item)); }(item));
} }
, changeServerItemState: function ($glyph, event) {
var newClass = "icon-folder-closed"
, client = event.shift()
, state = event.shift()
;
switch (state) {
case 2:
case 5:
newClass = "icon-loading";
break;
case 3:
newClass = "icon-exclamation-sign";
break;
case 4:
newClass = "icon-ok-sign";
break;
case 6:
newClass = "icon-folder-open";
break;
default:
case 0:
case 1:
newClass = "icon-folder-closed";
break;
}
$glyph.removeClass();
$glyph.addClass(newClass);
}
}); });
}); });
Loading…
Cancel
Save