You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
2.3 KiB
125 lines
2.3 KiB
/*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"
|
|
//, "toggleView"
|
|
, "destroyView"
|
|
);
|
|
//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
|
|
;
|
|
|
|
if (that.current === name) {
|
|
return true;
|
|
}
|
|
|
|
if (that.current) {
|
|
that.hideView(that.current);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
if (that.children[name].show) {
|
|
setTimeout(function __fnTimeoutMainViewShow() {
|
|
that.children[name].show();
|
|
}, 50);
|
|
} else {
|
|
setTimeout(function __fnTimeoutMainViewShow() {
|
|
that.children[name].$el.show();
|
|
}, 50);
|
|
}
|
|
}
|
|
}
|
|
, hideView: function (name) {
|
|
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();
|
|
} else {
|
|
that.children[name].$el.hide();
|
|
}
|
|
|
|
setTimeout(function __fnTimeoutMainViewHide() {
|
|
that.$el.find(that.children[name].$el).remove();
|
|
}, 50);
|
|
}
|
|
}
|
|
/*
|
|
, toggleView: function (name) {
|
|
var that = this
|
|
;
|
|
|
|
if (that.children[name] && that.children[name].$el) {
|
|
that.children[name].$el.toggle();
|
|
}
|
|
}
|
|
*/
|
|
, destroyView: function (name) {
|
|
|
|
}
|
|
});
|
|
|
|
return Main;
|
|
}); |