forked from Aintaer/nbd.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathController.js
36 lines (29 loc) · 807 Bytes
/
Controller.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* istanbul ignore if */
if (typeof define !== 'function') { var define = require('amdefine')(module); }
define([
'./Class',
'./util/construct'
], function(Class, construct) {
"use strict";
var constructor = Class.extend({
destroy: function() {},
_initView: function() {
var ViewClass = Array.prototype.shift.call(arguments);
this._view = construct.apply(ViewClass, arguments);
this._view._controller = this;
},
switchView: function() {
var existing = this._view;
this._initView.apply(this, arguments);
if (!existing) { return; }
if (existing.$view) {
this._view.$view = existing.$view;
this._view.render();
}
existing.destroy();
}
}, {
displayName: 'Controller'
});
return constructor;
});