|
|
@ -773,34 +773,40 @@ |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
BI.watch = function (vm, watch, handler) { |
|
|
|
BI.watch = function (vm, watch, handler) { |
|
|
|
if (BI.Widget.current) { |
|
|
|
if (vm instanceof BI.Model) { |
|
|
|
if (vm instanceof BI.Model) { |
|
|
|
var watchers = []; |
|
|
|
BI.Widget.current._watchers || (BI.Widget.current._watchers = []); |
|
|
|
if (BI.isKey(watch)) { |
|
|
|
if (BI.isKey(watch)) { |
|
|
|
var k = watch; |
|
|
|
var k = watch; |
|
|
|
watch = {}; |
|
|
|
watch = {}; |
|
|
|
watch[k] = handler; |
|
|
|
watch[k] = handler; |
|
|
|
} |
|
|
|
} |
|
|
|
for (var key in watch) { |
|
|
|
for (var key in watch) { |
|
|
|
var innerHandler = watch[key]; |
|
|
|
var handler = watch[key]; |
|
|
|
if (BI.isArray(handler)) { |
|
|
|
if (BI.isArray(handler)) { |
|
|
|
for (var i = 0; i < handler.length; i++) { |
|
|
|
for (var i = 0; i < handler.length; i++) { |
|
|
|
watchers.push(Fix.watch(vm.model, key, innerHandler, { |
|
|
|
BI.Widget.current._watchers.push(Fix.watch(vm.model, key, handler, { |
|
|
|
|
|
|
|
store: vm |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
BI.Widget.current._watchers.push(Fix.watch(vm.model, key, handler, { |
|
|
|
|
|
|
|
store: vm |
|
|
|
store: vm |
|
|
|
})); |
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
watchers.push(Fix.watch(vm.model, key, innerHandler, { |
|
|
|
|
|
|
|
store: vm |
|
|
|
|
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
handler = watch; |
|
|
|
|
|
|
|
watch = vm; |
|
|
|
|
|
|
|
BI.Widget.current.$watchDelayCallbacks || (BI.Widget.current.$watchDelayCallbacks = []); |
|
|
|
|
|
|
|
BI.Widget.current.$watchDelayCallbacks.push([watch, handler]); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (vm._widget) { |
|
|
|
|
|
|
|
vm._widget._watchers || (vm._widget._watchers = []); |
|
|
|
|
|
|
|
vm._widget._watchers = vm._widget._watchers.concat(watchers); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (BI.Widget.current) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handler = watch; |
|
|
|
|
|
|
|
watch = vm; |
|
|
|
|
|
|
|
BI.Widget.current.$watchDelayCallbacks || (BI.Widget.current.$watchDelayCallbacks = []); |
|
|
|
|
|
|
|
BI.Widget.current.$watchDelayCallbacks.push([watch, handler]); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|