|
|
|
/*jslint laxbreak:true */
|
|
|
|
/*jslint laxcomma:true */
|
|
|
|
/*jslint loopfunc:true */
|
|
|
|
/*jslint strict:true */
|
|
|
|
/*jslint browser:true */
|
|
|
|
/*jslint devel:true */
|
|
|
|
define([
|
|
|
|
"underscore"
|
|
|
|
, "jquery"
|
|
|
|
, "backbone"
|
|
|
|
|
|
|
|
, "views/list"
|
|
|
|
, "views/client"
|
|
|
|
]
|
|
|
|
, function (
|
|
|
|
_
|
|
|
|
, $
|
|
|
|
, Backbone
|
|
|
|
|
|
|
|
, ListView
|
|
|
|
, ClientView
|
|
|
|
) {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var Main = Backbone.View.extend({
|
|
|
|
children: {}
|
|
|
|
, current: null
|
|
|
|
|
|
|
|
, initialize: function (options) {
|
|
|
|
_.bindAll(this
|
|
|
|
, "setView"
|
|
|
|
, "getView"
|
|
|
|
, "showView"
|
|
|
|
, "hideView"
|
|
|
|
, "resizeView"
|
|
|
|
//, "toggleView"
|
|
|
|
, "destroyView"
|
|
|
|
, "_setPlayOrder"
|
|
|
|
);
|
|
|
|
//that.setView("playlist", new ListView(playlistCollection));
|
|
|
|
|
|
|
|
Main.__super__.initialize.apply(this, arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
, setView: function (name, view) {
|
|
|
|
var that = this
|
|
|
|
;
|
|
|
|
|
|
|
|
console.debug("Set view: "+ name, view);
|
|
|
|
that.children[name] = view;
|
|
|
|
}
|
|
|
|
|
|
|
|
, getView: function (name) {
|
|
|
|
var that = this
|
|
|
|
;
|
|
|
|
|
|
|
|
return that.children[name];
|
|
|
|
}
|
|
|
|
|
|
|
|
, showView: function (name) {
|
|
|
|
var that = this
|
|
|
|
, __fnShow = function () {
|
|
|
|
that.current = name;
|
|
|
|
|
|
|
|
console.debug("Show view: "+ name);//, that.$el, that.children[name], that.children[name].$el);
|
|
|
|
if (that.children[name] && that.children[name].$el) {
|
|
|
|
if (that.$el.find(that.children[name].$el).length === 0) {
|
|
|
|
that.$el.append(that.children[name].$el);
|
|
|
|
}
|
|
|
|
|
|
|
|
that.children[name].on("action:playorder", that._setPlayOrder);
|
|
|
|
|
|
|
|
if (that.children[name].show) {
|
|
|
|
that.children[name].show();
|
|
|
|
}
|
|
|
|
|
|
|
|
that.children[name].$el.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
if (that.current === name) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (that.current) {
|
|
|
|
that.hideView(that.current, __fnShow);
|
|
|
|
} else {
|
|
|
|
__fnShow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
, hideView: function (name, callback) {
|
|
|
|
var that = this
|
|
|
|
;
|
|
|
|
|
|
|
|
that.current = null;
|
|
|
|
|
|
|
|
console.debug("Hide view: "+ name);
|
|
|
|
if (that.children[name] && that.children[name].$el) {
|
|
|
|
|
|
|
|
if (that.children[name].hide) {
|
|
|
|
that.children[name].hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
that.children[name].$el.hide();
|
|
|
|
|
|
|
|
that.children[name].off("action:player");
|
|
|
|
|
|
|
|
setTimeout(function __fnTimeoutMainViewHide() {
|
|
|
|
that.children[name].$el.detach();
|
|
|
|
|
|
|
|
delete that.current;
|
|
|
|
|
|
|
|
return callback && callback();
|
|
|
|
}, 50);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
, resizeView: function (name) {
|
|
|
|
var that = this
|
|
|
|
;
|
|
|
|
|
|
|
|
if (that.current && that.children[that.current].resize) {
|
|
|
|
that.children[that.current].resize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
, toggleView: function (name) {
|
|
|
|
var that = this
|
|
|
|
;
|
|
|
|
|
|
|
|
if (that.children[name] && that.children[name].$el) {
|
|
|
|
that.children[name].$el.toggle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
, destroyView: function (name) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
, _setPlayOrder: function (event) {
|
|
|
|
var that = this
|
|
|
|
;
|
|
|
|
|
|
|
|
that.trigger.apply(that, ["action:playorder", event]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return Main;
|
|
|
|
});
|