|
|
@ -1,5 +1,5 @@ |
|
|
|
;(function () { |
|
|
|
;(function () { |
|
|
|
function initWatch (vm, watch) { |
|
|
|
function initWatch(vm, watch) { |
|
|
|
vm._watchers || (vm._watchers = []); |
|
|
|
vm._watchers || (vm._watchers = []); |
|
|
|
for (var key in watch) { |
|
|
|
for (var key in watch) { |
|
|
|
var handler = watch[key]; |
|
|
|
var handler = watch[key]; |
|
|
@ -13,7 +13,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function createWatcher (vm, keyOrFn, handler) { |
|
|
|
function createWatcher(vm, keyOrFn, handler) { |
|
|
|
return Fix.watch(vm.model, keyOrFn, _.bind(handler, vm), { |
|
|
|
return Fix.watch(vm.model, keyOrFn, _.bind(handler, vm), { |
|
|
|
store: vm.store |
|
|
|
store: vm.store |
|
|
|
}); |
|
|
|
}); |
|
|
@ -22,24 +22,24 @@ |
|
|
|
var target = null; |
|
|
|
var target = null; |
|
|
|
var targetStack = []; |
|
|
|
var targetStack = []; |
|
|
|
|
|
|
|
|
|
|
|
function pushTarget (_target) { |
|
|
|
function pushTarget(_target) { |
|
|
|
if (target) targetStack.push(target); |
|
|
|
if (target) targetStack.push(target); |
|
|
|
Fix.Model.target = target = _target; |
|
|
|
Fix.Model.target = target = _target; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function popTarget () { |
|
|
|
function popTarget() { |
|
|
|
Fix.Model.target = target = targetStack.pop(); |
|
|
|
Fix.Model.target = target = targetStack.pop(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var context = null; |
|
|
|
var context = null; |
|
|
|
var contextStack = []; |
|
|
|
var contextStack = []; |
|
|
|
|
|
|
|
|
|
|
|
function pushContext (_context) { |
|
|
|
function pushContext(_context) { |
|
|
|
if (context) contextStack.push(context); |
|
|
|
if (context) contextStack.push(context); |
|
|
|
Fix.Model.context = context = _context; |
|
|
|
Fix.Model.context = context = _context; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function popContext () { |
|
|
|
function popContext() { |
|
|
|
Fix.Model.context = context = contextStack.pop(); |
|
|
|
Fix.Model.context = context = contextStack.pop(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -60,7 +60,7 @@ |
|
|
|
}, options); |
|
|
|
}, options); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
function findStore (widget) { |
|
|
|
function findStore(widget) { |
|
|
|
if (target != null) { |
|
|
|
if (target != null) { |
|
|
|
return target; |
|
|
|
return target; |
|
|
|
} |
|
|
|
} |
|
|
@ -106,12 +106,11 @@ |
|
|
|
}; |
|
|
|
}; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var _init = BI.Widget.prototype._init; |
|
|
|
function createStore() { |
|
|
|
BI.Widget.prototype._init = function () { |
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
|
|
|
var needPop = false; |
|
|
|
var needPop = false; |
|
|
|
if (window.Fix && this._store) { |
|
|
|
if (!this._storeCreated && window.Fix && this._store && this.isVisible()) { |
|
|
|
var store = findStore(this.options.context || this.options.element); |
|
|
|
var store = findStore(this.options.context || this.options.element); |
|
|
|
|
|
|
|
this._storeCreated = true; |
|
|
|
if (store) { |
|
|
|
if (store) { |
|
|
|
pushTarget(store); |
|
|
|
pushTarget(store); |
|
|
|
needPop = true; |
|
|
|
needPop = true; |
|
|
@ -128,6 +127,13 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
needPop = true; |
|
|
|
needPop = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return needPop; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _init = BI.Widget.prototype._init; |
|
|
|
|
|
|
|
BI.Widget.prototype._init = function () { |
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
|
|
|
var needPop = createStore.call(this); |
|
|
|
_init.apply(this, arguments); |
|
|
|
_init.apply(this, arguments); |
|
|
|
needPop && popTarget(); |
|
|
|
needPop && popTarget(); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -166,6 +172,7 @@ |
|
|
|
_.each(["_mount"], function (name) { |
|
|
|
_.each(["_mount"], function (name) { |
|
|
|
var old = BI.Widget.prototype[name]; |
|
|
|
var old = BI.Widget.prototype[name]; |
|
|
|
old && (BI.Widget.prototype[name] = function () { |
|
|
|
old && (BI.Widget.prototype[name] = function () { |
|
|
|
|
|
|
|
createStore.call(this); |
|
|
|
this.store && pushTarget(this.store); |
|
|
|
this.store && pushTarget(this.store); |
|
|
|
var res = old.apply(this, arguments); |
|
|
|
var res = old.apply(this, arguments); |
|
|
|
this.store && popTarget(); |
|
|
|
this.store && popTarget(); |
|
|
|