Browse Source

Merge pull request #162 in FUI/fineui from ~GUY/fineui:master to master

* commit '05a008e4cbd993e27c6c194dc7e8b17832c0fbb4':
  update
  update
  update
  update
  update
  BI-11060 firefox下拉菜单有条黄线
es6
guy 7 years ago
parent
commit
41a7212cea
  1. 4
      bi/core.js
  2. 22
      demo/js/config/fix.js
  3. 52
      demo/js/fix-2.0/computed.js
  4. 45
      demo/js/fix-2.0/define.js
  5. 57
      demo/js/fix-2.0/demo.js
  6. 60
      demo/js/fix-2.0/store.js
  7. 51
      demo/js/fix-2.0/watcher.js
  8. 4
      dist/bundle.js
  9. 6
      dist/bundle.min.js
  10. 4
      dist/core.js
  11. 282
      dist/demo.js
  12. 66
      dist/fix/fix.js
  13. 4
      src/core/controller/controller.tooltips.js

4
bi/core.js

@ -18683,7 +18683,9 @@ BI.TooltipsController = BI.inherit(BI.Controller, {
var offset = context.element.offset(); var offset = context.element.offset();
var bounds = context.element.bounds(); var bounds = context.element.bounds();
if(bounds.height === 0 || bounds.width === 0) {
return;
}
var top = offset.top + bounds.height + 5; var top = offset.top + bounds.height + 5;
var tooltip = this.get(name); var tooltip = this.get(name);
tooltip.setText(text); tooltip.setText(text);

22
demo/js/config/fix.js

@ -86,6 +86,26 @@ Demo.FIX_CONFIG = [{
}, { }, {
id: 71, id: 71,
pId: 7, pId: 7,
text: "fix框架", text: "定义响应式数据",
value: "demo.fix1"
}, {
id: 72,
pId: 7,
text: "计算属性",
value: "demo.fix2"
}, {
id: 73,
pId: 7,
text: "store",
value: "demo.fix3"
}, {
id: 74,
pId: 7,
text: "watcher表达式",
value: "demo.fix4"
}, {
id: 75,
pId: 7,
text: "一个混合的例子",
value: "demo.fix" value: "demo.fix"
}]; }];

52
demo/js/fix-2.0/computed.js

@ -0,0 +1,52 @@
;(function(){
var model = Fix.define({
name: "原始属性",
arr: [{
n: 'a'
}, {
n: 'b'
}]
});
var Computed = BI.inherit(Fix.VM, {
computed: {
b: function () {
return this.name + "-计算属性"
}
}
})
Demo.Fix = BI.inherit(BI.Widget, {
_store: function () {
return new Computed(model);
},
watch: {
b: function () {
this.button.setText(this.model.b)
}
},
render: function () {
var self = this;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.button",
ref: function () {
self.button = this;
},
handler: function () {
self.model.name = "这是改变后的属性"
},
text: this.model.b
}
}]
}
},
mounted: function () {
}
});
BI.shortcut("demo.fix2", Demo.Fix);
}());

45
demo/js/fix-2.0/define.js

@ -0,0 +1,45 @@
;(function () {
var model = Fix.define({
name: "原始属性",
arr: [{
n: 'a'
}, {
n: 'b'
}]
});
Demo.Fix = BI.inherit(BI.Widget, {
_store: function () {
return model;
},
watch: {
name: function () {
this.button.setText(this.model.name)
}
},
render: function () {
var self = this;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.button",
ref: function () {
self.button = this;
},
handler: function () {
self.model.name = "这是改变后的属性"
},
text: this.model.name
}
}]
}
},
mounted: function () {
}
});
BI.shortcut("demo.fix1", Demo.Fix);
}());

57
demo/js/fix-2.0/demo.js

@ -1,12 +1,13 @@
var model = Fix.define({ ;(function () {
var model = Fix.define({
name: 1, name: 1,
arr: [{ arr: [{
n: 'a' n: 'a'
}, { }, {
n: 'b' n: 0
}] }]
}); });
Demo.Computed = BI.inherit(Fix.VM, { var Computed = BI.inherit(Fix.VM, {
computed: { computed: {
b: function () { b: function () {
return this.name + 1 return this.name + 1
@ -15,38 +16,60 @@ Demo.Computed = BI.inherit(Fix.VM, {
return this.arr[1].n + this.b return this.arr[1].n + this.b
} }
} }
}) })
Demo.Store = BI.inherit(Fix.VM, { var Store = BI.inherit(Fix.VM, {
_init: function () { _init: function () {
this.comp = new Demo.Computed(model).model; this.comp = new Computed(model).model;
}, },
computed: { computed: {
b: function () { b: function () {
return this.comp.c + 1 return this.comp.c + 1
},
c: function () {
return this.comp.arr[1].n & 1;
} }
}, },
actions: { actions: {
run: function () { run: function () {
this.comp.name = 2; this.comp.name++;
this.comp.arr[1].n = "c" this.comp.arr[1].n++;
} }
} }
}); });
Demo.Fix = BI.inherit(BI.Widget, { Demo.Fix = BI.inherit(BI.Widget, {
_store: function () { _store: function () {
return new Demo.Store(); return new Store();
}, },
watch: { watch: {
b: function () { "b&&(c||b)": function () {
debugger; this.button.setText(this.model.b)
}
},
render: function () {
var self = this;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.button",
ref: function () {
self.button = this;
},
handler: function () {
self.store.run()
},
text: this.model.b
}
}]
} }
}, },
mounted: function () { mounted: function () {
this.store.run()
} }
}); });
BI.shortcut("demo.fix", Demo.Fix); BI.shortcut("demo.fix", Demo.Fix);
}());

60
demo/js/fix-2.0/store.js

@ -0,0 +1,60 @@
;(function(){
var model = Fix.define({
name: "原始属性",
arr: [{
n: 'a'
}, {
n: 'b'
}]
});
var Store = BI.inherit(Fix.VM, {
_init: function () {
},
computed: {
b: function () {
return model.name + '-计算属性'
}
},
actions: {
run: function () {
model.name = "这是改变后的属性";
}
}
});
Demo.Fix = BI.inherit(BI.Widget, {
_store: function () {
return new Store();
},
watch: {
b: function () {
this.button.setText(this.model.b)
}
},
render: function () {
var self = this;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.button",
ref: function () {
self.button = this;
},
handler: function () {
self.store.run()
},
text: this.model.b
}
}]
}
},
mounted: function () {
}
});
BI.shortcut("demo.fix3", Demo.Fix);
}());

51
demo/js/fix-2.0/watcher.js

@ -0,0 +1,51 @@
;(function () {
var model = Fix.define({
name: "原始属性",
arr: [{
n: 'a'
}, {
n: 0
}]
});
Demo.Fix = BI.inherit(BI.Widget, {
_store: function () {
return model;
},
watch: {
"name||arr.1.n": function () {
this.button.setText(this.model.name + "-" + this.model.arr[1].n)
}
},
render: function () {
var self = this;
var cnt = 0;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.button",
ref: function () {
self.button = this;
},
handler: function () {
if (cnt & 1) {
self.model.name += 1;
} else {
self.model.arr[1].n += 1;
}
cnt++;
},
text: this.model.name + "-" + this.model.arr[1].n
}
}]
}
},
mounted: function () {
}
});
BI.shortcut("demo.fix4", Demo.Fix);
}());

4
dist/bundle.js vendored

@ -18734,7 +18734,9 @@ BI.TooltipsController = BI.inherit(BI.Controller, {
var offset = context.element.offset(); var offset = context.element.offset();
var bounds = context.element.bounds(); var bounds = context.element.bounds();
if(bounds.height === 0 || bounds.width === 0) {
return;
}
var top = offset.top + bounds.height + 5; var top = offset.top + bounds.height + 5;
var tooltip = this.get(name); var tooltip = this.get(name);
tooltip.setText(text); tooltip.setText(text);

6
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

4
dist/core.js vendored

@ -18683,7 +18683,9 @@ BI.TooltipsController = BI.inherit(BI.Controller, {
var offset = context.element.offset(); var offset = context.element.offset();
var bounds = context.element.bounds(); var bounds = context.element.bounds();
if(bounds.height === 0 || bounds.width === 0) {
return;
}
var top = offset.top + bounds.height + 5; var top = offset.top + bounds.height + 5;
var tooltip = this.get(name); var tooltip = this.get(name);
tooltip.setText(text); tooltip.setText(text);

282
dist/demo.js vendored

@ -5381,7 +5381,27 @@ Demo.FIX_CONFIG = [{
}, { }, {
id: 71, id: 71,
pId: 7, pId: 7,
text: "fix框架", text: "定义响应式数据",
value: "demo.fix1"
}, {
id: 72,
pId: 7,
text: "计算属性",
value: "demo.fix2"
}, {
id: 73,
pId: 7,
text: "store",
value: "demo.fix3"
}, {
id: 74,
pId: 7,
text: "watcher表达式",
value: "demo.fix4"
}, {
id: 75,
pId: 7,
text: "一个混合的例子",
value: "demo.fix" value: "demo.fix"
}];Demo.WIDGET_CONFIG = [{ }];Demo.WIDGET_CONFIG = [{
id: 4, id: 4,
@ -10070,15 +10090,112 @@ Demo.Func = BI.inherit(BI.Widget, {
} }
}); });
BI.shortcut("demo.tmp", Demo.Func); BI.shortcut("demo.tmp", Demo.Func);
var model = Fix.define({ ;(function(){
name: 1, var model = Fix.define({
name: "原始属性",
arr: [{ arr: [{
n: 'a' n: 'a'
}, { }, {
n: 'b' n: 'b'
}] }]
}); });
Demo.Computed = BI.inherit(Fix.VM, { var Computed = BI.inherit(Fix.VM, {
computed: {
b: function () {
return this.name + "-计算属性"
}
}
})
Demo.Fix = BI.inherit(BI.Widget, {
_store: function () {
return new Computed(model);
},
watch: {
b: function () {
this.button.setText(this.model.b)
}
},
render: function () {
var self = this;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.button",
ref: function () {
self.button = this;
},
handler: function () {
self.model.name = "这是改变后的属性"
},
text: this.model.b
}
}]
}
},
mounted: function () {
}
});
BI.shortcut("demo.fix2", Demo.Fix);
}());;(function () {
var model = Fix.define({
name: "原始属性",
arr: [{
n: 'a'
}, {
n: 'b'
}]
});
Demo.Fix = BI.inherit(BI.Widget, {
_store: function () {
return model;
},
watch: {
name: function () {
this.button.setText(this.model.name)
}
},
render: function () {
var self = this;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.button",
ref: function () {
self.button = this;
},
handler: function () {
self.model.name = "这是改变后的属性"
},
text: this.model.name
}
}]
}
},
mounted: function () {
}
});
BI.shortcut("demo.fix1", Demo.Fix);
}());
;(function () {
var model = Fix.define({
name: 1,
arr: [{
n: 'a'
}, {
n: 0
}]
});
var Computed = BI.inherit(Fix.VM, {
computed: { computed: {
b: function () { b: function () {
return this.name + 1 return this.name + 1
@ -10087,41 +10204,172 @@ Demo.Computed = BI.inherit(Fix.VM, {
return this.arr[1].n + this.b return this.arr[1].n + this.b
} }
} }
}) })
Demo.Store = BI.inherit(Fix.VM, { var Store = BI.inherit(Fix.VM, {
_init: function () { _init: function () {
this.comp = new Demo.Computed(model).model; this.comp = new Computed(model).model;
}, },
computed: { computed: {
b: function () { b: function () {
return this.comp.c + 1 return this.comp.c + 1
},
c: function () {
return this.comp.arr[1].n & 1;
} }
}, },
actions: { actions: {
run: function () { run: function () {
this.comp.name = 2; this.comp.name++;
this.comp.arr[1].n = "c" this.comp.arr[1].n++;
} }
} }
}); });
Demo.Fix = BI.inherit(BI.Widget, {
_store: function () {
return new Store();
},
watch: {
"b&&(c||b)": function () {
this.button.setText(this.model.b)
}
},
render: function () {
var self = this;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.button",
ref: function () {
self.button = this;
},
handler: function () {
self.store.run()
},
text: this.model.b
}
}]
}
},
mounted: function () {
Demo.Fix = BI.inherit(BI.Widget, {
}
});
BI.shortcut("demo.fix", Demo.Fix);
}());;(function(){
var model = Fix.define({
name: "原始属性",
arr: [{
n: 'a'
}, {
n: 'b'
}]
});
var Store = BI.inherit(Fix.VM, {
_init: function () {
},
computed: {
b: function () {
return model.name + '-计算属性'
}
},
actions: {
run: function () {
model.name = "这是改变后的属性";
}
}
});
Demo.Fix = BI.inherit(BI.Widget, {
_store: function () { _store: function () {
return new Demo.Store(); return new Store();
}, },
watch: { watch: {
b: function () { b: function () {
debugger; this.button.setText(this.model.b)
}
},
render: function () {
var self = this;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.button",
ref: function () {
self.button = this;
},
handler: function () {
self.store.run()
},
text: this.model.b
}
}]
} }
}, },
mounted: function () { mounted: function () {
this.store.run()
} }
}); });
BI.shortcut("demo.fix3", Demo.Fix);
}());;(function () {
var model = Fix.define({
name: "原始属性",
arr: [{
n: 'a'
}, {
n: 0
}]
});
Demo.Fix = BI.inherit(BI.Widget, {
_store: function () {
return model;
},
watch: {
"name||arr.1.n": function () {
this.button.setText(this.model.name + "-" + this.model.arr[1].n)
}
},
render: function () {
var self = this;
var cnt = 0;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.button",
ref: function () {
self.button = this;
},
handler: function () {
if (cnt & 1) {
self.model.name += 1;
} else {
self.model.arr[1].n += 1;
}
cnt++;
},
text: this.model.name + "-" + this.model.arr[1].n
}
}]
}
},
mounted: function () {
}
});
BI.shortcut("demo.fix", Demo.Fix);Demo.Main = BI.inherit(BI.Widget, { BI.shortcut("demo.fix4", Demo.Fix);
}());Demo.Main = BI.inherit(BI.Widget, {
props: { props: {
baseCls: "demo-main bi-background" baseCls: "demo-main bi-background"
}, },

66
dist/fix/fix.js vendored

@ -438,14 +438,15 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
return ob; return ob;
} }
function defineReactive(obj, shallow) { function defineReactive(obj, observer, shallow) {
var props = {}; var props = {};
_.each(obj, function (val, key) { _.each(obj, function (val, key) {
if (key in $$skipArray) { if (key in $$skipArray) {
return; return;
} }
var dep = new Dep(); var dep = observer && observer['__dep' + key] || new Dep();
observer && (observer['__dep' + key] = dep);
var childOb = !shallow && observe(val); var childOb = !shallow && observe(val);
props[key] = { props[key] = {
enumerable: true, enumerable: true,
@ -501,9 +502,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
target[key] = val; target[key] = val;
return val; return val;
} }
defineReactive(ob.value, key, val); ob.value[key] = val;
target = defineReactive(ob.value, ob);
ob.dep.notify(); ob.dep.notify();
return val; return target;
} }
/** /**
@ -521,11 +523,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
if (!_.has(target, key)) { if (!_.has(target, key)) {
return; return;
} }
delete target[key];
if (!ob) { if (!ob) {
return; delete target[key];
return target;
} }
delete ob.value[key];
target = defineReactive(ob.value, ob);
ob.dep.notify(); ob.dep.notify();
return target;
} }
/** /**
@ -870,6 +875,26 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
return vm.$watch(keyOrFn, handler, options); return vm.$watch(keyOrFn, handler, options);
} }
var falsy$1;
var operators = {
'||': falsy$1,
'&&': falsy$1,
'(': falsy$1,
')': falsy$1
};
function runBinaryFunction(binarys) {
var expr = '';
for (var i = 0, len = binarys.length; i < len; i++) {
if (_.isBoolean(binarys[i]) || _.has(operators, binarys[i])) {
expr += binarys[i];
} else {
expr += 'false';
}
}
return new Function('return ' + expr)();
}
var VM = function () { var VM = function () {
function VM(model) { function VM(model) {
_classCallCheck(this, VM); _classCallCheck(this, VM);
@ -922,6 +947,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
} }
options = options || {}; options = options || {};
options.user = true; options.user = true;
var exps = void 0;
if (_.isFunction(expOrFn) || !(exps = expOrFn.match(/[a-zA-Z0-9_.]+|[|][|]|[&][&]|[(]|[)]/g)) || exps.length === 1) {
var watcher = new Watcher(vm.model, expOrFn, _.bind(cb, vm), options); var watcher = new Watcher(vm.model, expOrFn, _.bind(cb, vm), options);
if (options.immediate) { if (options.immediate) {
cb.call(vm, watcher.value); cb.call(vm, watcher.value);
@ -929,6 +956,33 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
return function unwatchFn() { return function unwatchFn() {
watcher.teardown(); watcher.teardown();
}; };
}
var watchers = [];
var fns = exps.slice();
var complete = false;
_.each(exps, function (exp, i) {
if (_.has(operators, exp)) {
return;
}
var watcher = new Watcher(vm.model, exp, function () {
if (complete === true) {
return;
}
fns[i] = true;
if (runBinaryFunction(fns)) {
complete = true;
cb.call(vm);
fns = exps.slice();
nextTick(function () {
complete = false;
});
}
}, options);
watchers.push(function unwatchFn() {
watcher.teardown();
});
});
return watchers;
}; };
VM.prototype._init = function _init() {}; VM.prototype._init = function _init() {};

4
src/core/controller/controller.tooltips.js

@ -71,7 +71,9 @@ BI.TooltipsController = BI.inherit(BI.Controller, {
var offset = context.element.offset(); var offset = context.element.offset();
var bounds = context.element.bounds(); var bounds = context.element.bounds();
if(bounds.height === 0 || bounds.width === 0) {
return;
}
var top = offset.top + bounds.height + 5; var top = offset.top + bounds.height + 5;
var tooltip = this.get(name); var tooltip = this.get(name);
tooltip.setText(text); tooltip.setText(text);

Loading…
Cancel
Save