1
0
Fork 0
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.

122 lines
2.2 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) {
console.log(that.$el.find(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) {
that.children[name].show();
} else {
that.children[name].$el.show();
}
}
}
, 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).detach();
}, 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;
});