@ -1,136 +0,0 @@ |
|||||||
Demo.CanvasTable = BI.inherit(BI.Widget, { |
|
||||||
props: { |
|
||||||
baseCls: "demo-face" |
|
||||||
}, |
|
||||||
|
|
||||||
render: function () { |
|
||||||
var self = this; |
|
||||||
return { |
|
||||||
type: "bi.absolute", |
|
||||||
items: [{ |
|
||||||
el: { |
|
||||||
type: "bi.sequence_table", |
|
||||||
ref: function () { |
|
||||||
self.table = this; |
|
||||||
}, |
|
||||||
isNeedFreeze: null, |
|
||||||
isNeedMerge: false, |
|
||||||
summaryCellStyleGetter: function (isLast) { |
|
||||||
return { |
|
||||||
background: "rgb(4, 177, 194)", |
|
||||||
color: "#ffffff", |
|
||||||
fontWeight: "bold" |
|
||||||
}; |
|
||||||
}, |
|
||||||
sequenceCellStyleGetter: function (index) { |
|
||||||
return { |
|
||||||
background: "rgb(4, 177, 194)", |
|
||||||
color: "#ffffff", |
|
||||||
fontWeight: "bold" |
|
||||||
}; |
|
||||||
}, |
|
||||||
headerCellStyleGetter: function () { |
|
||||||
return { |
|
||||||
background: "rgb(4, 177, 194)", |
|
||||||
color: "#ffffff", |
|
||||||
fontWeight: "bold" |
|
||||||
}; |
|
||||||
}, |
|
||||||
el: { |
|
||||||
type: "bi.adaptive_table", |
|
||||||
el: { |
|
||||||
type: "bi.resizable_table", |
|
||||||
el: { |
|
||||||
type: "bi.canvas_table" |
|
||||||
} |
|
||||||
} |
|
||||||
}, |
|
||||||
sequence: { |
|
||||||
type: "bi.sequence_table_list_number", |
|
||||||
pageSize: 100, |
|
||||||
sequenceHeaderCreator: { |
|
||||||
type: "bi.normal_sequence_header_cell", |
|
||||||
styleGetter: function () { |
|
||||||
return { |
|
||||||
background: "rgb(4, 177, 194)", |
|
||||||
color: "#ffffff", |
|
||||||
fontWeight: "bold" |
|
||||||
}; |
|
||||||
} |
|
||||||
} |
|
||||||
}, |
|
||||||
itemsCreator: function (op, populate) { |
|
||||||
} |
|
||||||
}, |
|
||||||
left: 0, |
|
||||||
right: 0, |
|
||||||
top: 0, |
|
||||||
bottom: 0 |
|
||||||
}] |
|
||||||
}; |
|
||||||
}, |
|
||||||
|
|
||||||
mounted: function () { |
|
||||||
var self = this; |
|
||||||
if (BI.isNull(BI.isExpanded)) { |
|
||||||
BI.isExpanded = false; |
|
||||||
} else if (!BI.isExpanded) { |
|
||||||
TABLE_ITEMS = this._expandData(TABLE_ITEMS, 3); |
|
||||||
TABLE_HEADER = this._expandHeadData(TABLE_HEADER, 3); |
|
||||||
BI.isExpanded = true; |
|
||||||
} |
|
||||||
this._resizeHandler = BI.debounce(function () { |
|
||||||
var width = self.element.width(), height = self.element.height(); |
|
||||||
if (self.table.getWidth() !== width || self.table.getHeight() !== height) { |
|
||||||
self.table.setWidth(width); |
|
||||||
self.table.setHeight(height); |
|
||||||
self.table.populate(); |
|
||||||
} |
|
||||||
}, 0); |
|
||||||
BI.ResizeDetector.addResizeListener(this, function () { |
|
||||||
self._resizeHandler(); |
|
||||||
}); |
|
||||||
this.table.setWidth(this.element.width()); |
|
||||||
this.table.setHeight(this.element.height()); |
|
||||||
this.table.attr("columnSize", BI.makeArray(TABLE_HEADER[0].length, "")); |
|
||||||
this.table.attr("minColumnSize", BI.makeArray(TABLE_HEADER[0].length, 60)); |
|
||||||
this.table.attr("isNeedFreeze", true); |
|
||||||
this.table.attr("freezeCols", []); |
|
||||||
this.table.attr("showSequence", true); |
|
||||||
this.table.attr("headerRowSize", 15); |
|
||||||
this.table.attr("rowSize", 15); |
|
||||||
this.table.populate(TABLE_ITEMS, TABLE_HEADER); |
|
||||||
}, |
|
||||||
|
|
||||||
_expandData: function (items, times) { |
|
||||||
var copy = BI.deepClone(items); |
|
||||||
for (var m = 0; m < times - 1; m++) { |
|
||||||
BI.each(items, function (i, row) { |
|
||||||
copy.push(row); |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
for (var n = 0; n < copy.length; n++) { |
|
||||||
for (var m = 0; m < times - 1; m++) { |
|
||||||
BI.each(items[n % 100], function (j, item) { |
|
||||||
copy[n].push(item); |
|
||||||
}) |
|
||||||
} |
|
||||||
} |
|
||||||
return copy; |
|
||||||
}, |
|
||||||
|
|
||||||
_expandHeadData: function (items, times) { |
|
||||||
var copy = BI.deepClone(items); |
|
||||||
for (var n = 0; n < copy.length; n++) { |
|
||||||
for (var m = 0; m < times - 1; m++) { |
|
||||||
BI.each(items[n], function (j, item) { |
|
||||||
copy[n].push(item); |
|
||||||
}) |
|
||||||
} |
|
||||||
} |
|
||||||
return copy; |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
BI.shortcut("demo.canvas_table", Demo.CanvasTable); |
|
@ -1,228 +0,0 @@ |
|||||||
/** |
|
||||||
* canvas绘图 |
|
||||||
* |
|
||||||
* Created by Shichao on 2017/09/29. |
|
||||||
* @class BI.CanvasNew |
|
||||||
* @extends BI.Widget |
|
||||||
*/ |
|
||||||
BI.CanvasNew = BI.inherit(BI.Widget, { |
|
||||||
|
|
||||||
_defaultConfig: function () { |
|
||||||
return BI.extend(BI.CanvasNew.superclass._defaultConfig.apply(this, arguments), { |
|
||||||
baseCls: "bi-canvas-new" |
|
||||||
}) |
|
||||||
}, |
|
||||||
|
|
||||||
_init: function () { |
|
||||||
BI.CanvasNew.superclass._init.apply(this, arguments); |
|
||||||
var self = this, o = this.options; |
|
||||||
var canvas = this._createHiDPICanvas(o.width, o.height); |
|
||||||
this.element.append(canvas); |
|
||||||
this.canvas = canvas; |
|
||||||
this._queue = []; |
|
||||||
}, |
|
||||||
|
|
||||||
_getContext: function () { |
|
||||||
if (!this.ctx) { |
|
||||||
this.ctx = this.canvas.getContext('2d'); |
|
||||||
} |
|
||||||
return this.ctx; |
|
||||||
}, |
|
||||||
|
|
||||||
getContext: function () { |
|
||||||
return this._getContext(); |
|
||||||
}, |
|
||||||
|
|
||||||
_getPixelRatio: function () { |
|
||||||
var ctx = document.createElement("canvas").getContext("2d"), |
|
||||||
dpr = window.devicePixelRatio || 1, |
|
||||||
bsr = ctx.webkitBackingStorePixelRatio || |
|
||||||
ctx.mozBackingStorePixelRatio || |
|
||||||
ctx.msBackingStorePixelRatio || |
|
||||||
ctx.oBackingStorePixelRatio || |
|
||||||
ctx.backingStorePixelRatio || 1; |
|
||||||
return dpr / bsr; |
|
||||||
}, |
|
||||||
|
|
||||||
getPixelRatio: function () { |
|
||||||
return this._getPixelRatio(); |
|
||||||
}, |
|
||||||
|
|
||||||
_createHiDPICanvas: function (w, h, ratio) { |
|
||||||
if (!ratio) { |
|
||||||
ratio = this._getPixelRatio(); |
|
||||||
} |
|
||||||
this.ratio = ratio; |
|
||||||
var canvas = document.createElement("canvas"); |
|
||||||
if (!document.createElement('canvas').getContext) { |
|
||||||
canvas = window.G_vmlCanvasManager.initElement(canvas); |
|
||||||
} |
|
||||||
canvas.width = w * ratio; |
|
||||||
canvas.height = h * ratio; |
|
||||||
canvas.style.width = w + "px"; |
|
||||||
canvas.style.height = h + "px"; |
|
||||||
canvas.getContext("2d").setTransform(ratio, 0, 0, ratio, 0, 0); |
|
||||||
return canvas; |
|
||||||
}, |
|
||||||
|
|
||||||
_attr: function (key, value) { |
|
||||||
var self = this; |
|
||||||
if (BI.isNull(key)) { |
|
||||||
return; |
|
||||||
} |
|
||||||
if (BI.isObject(key)) { |
|
||||||
BI.each(key, function (k, v) { |
|
||||||
self._queue.push({ k: k, v: v }); |
|
||||||
}); |
|
||||||
return; |
|
||||||
} |
|
||||||
this._queue.push({ k: key, v: value }); |
|
||||||
}, |
|
||||||
|
|
||||||
_line: function (x0, y0) { |
|
||||||
var self = this; |
|
||||||
var args = [].slice.call(arguments, 2); |
|
||||||
if (BI.isOdd(args.length)) { |
|
||||||
this._attr(BI.last(args)); |
|
||||||
args = BI.initial(args); |
|
||||||
} |
|
||||||
this._attr("moveTo", [x0, y0]); |
|
||||||
var odd = BI.filter(args, function (i) { |
|
||||||
return i % 2 === 0; |
|
||||||
}); |
|
||||||
var even = BI.filter(args, function (i) { |
|
||||||
return i % 2 !== 0; |
|
||||||
}); |
|
||||||
args = BI.zip(odd, even); |
|
||||||
BI.each(args, function (i, point) { |
|
||||||
self._attr("lineTo", point); |
|
||||||
}); |
|
||||||
}, |
|
||||||
|
|
||||||
line: function (x0, y0, x1, y1) { |
|
||||||
this._line.apply(this, arguments); |
|
||||||
this._attr("stroke", []); |
|
||||||
}, |
|
||||||
|
|
||||||
rect: function (x, y, w, h, color) { |
|
||||||
this._attr("fillStyle", color); |
|
||||||
this._attr("fillRect", [x, y, w, h]); |
|
||||||
}, |
|
||||||
|
|
||||||
circle: function (x, y, radius, color) { |
|
||||||
this._attr({ |
|
||||||
fillStyle: color, |
|
||||||
beginPath: [], |
|
||||||
arc: [x, y, radius, 0, Math.PI * 2, true], |
|
||||||
closePath: [], |
|
||||||
fill: [] |
|
||||||
}); |
|
||||||
}, |
|
||||||
|
|
||||||
hollow: function () { |
|
||||||
this._attr("beginPath", []); |
|
||||||
this._line.apply(this, arguments); |
|
||||||
this._attr("closePath", []); |
|
||||||
this._attr("stroke", []); |
|
||||||
}, |
|
||||||
|
|
||||||
solid: function () { |
|
||||||
this.hollow.apply(this, arguments); |
|
||||||
this._attr("fill", []); |
|
||||||
}, |
|
||||||
|
|
||||||
text: function (x, y, text, fillStyle) { |
|
||||||
this._attr("fillStyle", BI.isNull(fillStyle) ? "rgb(102, 102, 102)" : fillStyle); |
|
||||||
this._attr("fillText", [text, x, y]); |
|
||||||
}, |
|
||||||
|
|
||||||
setFontStyle: function (fontStyle) { |
|
||||||
this.fontStyle = fontStyle; |
|
||||||
}, |
|
||||||
|
|
||||||
setFontVariant: function (fontVariant) { |
|
||||||
this.fontVariant = fontVariant; |
|
||||||
}, |
|
||||||
|
|
||||||
setFontWeight: function (fontWeight) { |
|
||||||
this.fontWeight = fontWeight; |
|
||||||
}, |
|
||||||
|
|
||||||
setFontSize: function (fontSize) { |
|
||||||
this.fontSize = fontSize; |
|
||||||
}, |
|
||||||
|
|
||||||
setFontFamily: function (fontFamily) { |
|
||||||
this.fontFamily = fontFamily; |
|
||||||
}, |
|
||||||
|
|
||||||
setFont: function () { |
|
||||||
var fontStyle = this.fontStyle || "", |
|
||||||
fontVariant = this.fontVariant || "", |
|
||||||
fontWeight = this.fontWeight || "", |
|
||||||
fontSize = this.fontSize || "12px", |
|
||||||
fontFamily = this.fontFamily || "sans-serif", |
|
||||||
font = fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSize + " " + fontFamily; |
|
||||||
this._getContext().font = font; |
|
||||||
}, |
|
||||||
|
|
||||||
gradient: function (x0, y0, x1, y1, start, end) { |
|
||||||
var grd = this._getContext().createLinearGradient(x0, y0, x1, y1); |
|
||||||
grd.addColorStop(0, start); |
|
||||||
grd.addColorStop(1, end); |
|
||||||
return grd; |
|
||||||
}, |
|
||||||
|
|
||||||
reset: function (x, y) { |
|
||||||
this._getContext().clearRect(x, y, this.canvas.width, this.canvas.height); |
|
||||||
}, |
|
||||||
|
|
||||||
remove: function (x, y, width, height) { |
|
||||||
this._getContext().clearRect(x, y, width, height); |
|
||||||
}, |
|
||||||
|
|
||||||
stroke: function (callback) { |
|
||||||
var self = this; |
|
||||||
BI.nextTick(function () { |
|
||||||
var ctx = self._getContext(); |
|
||||||
BI.each(self._queue, function (i, q) { |
|
||||||
if (BI.isFunction(ctx[q.k])) { |
|
||||||
ctx[q.k].apply(ctx, q.v); |
|
||||||
} else { |
|
||||||
ctx[q.k] = q.v; |
|
||||||
} |
|
||||||
}); |
|
||||||
self._queue = []; |
|
||||||
callback && callback(); |
|
||||||
}); |
|
||||||
}, |
|
||||||
|
|
||||||
setWidth: function (width) { |
|
||||||
BI.CanvasNew.superclass.setWidth.apply(this, arguments); |
|
||||||
this.ratio = this._getPixelRatio(); |
|
||||||
this.canvas.width = width * this.ratio; |
|
||||||
this.canvas.style.width = width + "px"; |
|
||||||
this.canvas.getContext("2d").setTransform(this.ratio, 0, 0, this.ratio, 0, 0); |
|
||||||
}, |
|
||||||
|
|
||||||
setHeight: function (height) { |
|
||||||
BI.CanvasNew.superclass.setHeight.apply(this, arguments); |
|
||||||
this.ratio = this._getPixelRatio(); |
|
||||||
this.canvas.height = height * this.ratio; |
|
||||||
this.canvas.style.height = height + "px"; |
|
||||||
this.canvas.getContext("2d").setTransform(this.ratio, 0, 0, this.ratio, 0, 0); |
|
||||||
}, |
|
||||||
|
|
||||||
setBlock: function () { |
|
||||||
this.canvas.style.display = "block"; |
|
||||||
}, |
|
||||||
|
|
||||||
transform: function (a, b, c, d, e, f) { |
|
||||||
this._attr("transform", [a, b, c, d, e, f]); |
|
||||||
}, |
|
||||||
|
|
||||||
translate: function (x, y) { |
|
||||||
this._attr("translate", [x, y]); |
|
||||||
} |
|
||||||
}); |
|
||||||
BI.shortcut("bi.canvas_new", BI.CanvasNew); |
|
@ -1,17 +1,17 @@ |
|||||||
Demo.ADDONS_CONFIG = [{ |
Demo.ADDONS_CONFIG = [{ |
||||||
id: 7, |
id: 1000, |
||||||
text: "addons" |
text: "addons" |
||||||
}, { |
}, { |
||||||
pId: 7, |
pId: 1000, |
||||||
id: 701, |
id: 1001, |
||||||
text: "拓展图表控件" |
text: "拓展图表控件" |
||||||
}, { |
}, { |
||||||
pId: 701, |
pId: 1001, |
||||||
text: "柱状图", |
text: "柱状图", |
||||||
value: "demo.axis_chart" |
value: "demo.axis_chart" |
||||||
}, { |
}, { |
||||||
pId: 7, |
pId: 1000, |
||||||
id: 702, |
id: 1002, |
||||||
text: "滚动sliders", |
text: "滚动sliders", |
||||||
value: "demo.slider" |
value: "demo.slider" |
||||||
}]; |
}]; |
@ -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); |
||||||
|
}()); |
@ -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); |
||||||
|
}()); |
@ -0,0 +1,75 @@ |
|||||||
|
;(function () { |
||||||
|
var model = Fix.define({ |
||||||
|
name: 1, |
||||||
|
arr: [{ |
||||||
|
n: 'a' |
||||||
|
}, { |
||||||
|
n: 0 |
||||||
|
}] |
||||||
|
}); |
||||||
|
var Computed = BI.inherit(Fix.VM, { |
||||||
|
computed: { |
||||||
|
b: function () { |
||||||
|
return this.name + 1 |
||||||
|
}, |
||||||
|
c: function () { |
||||||
|
return this.arr[1].n + this.b |
||||||
|
} |
||||||
|
} |
||||||
|
}) |
||||||
|
|
||||||
|
var Store = BI.inherit(Fix.VM, { |
||||||
|
_init: function () { |
||||||
|
this.comp = new Computed(model); |
||||||
|
}, |
||||||
|
computed: { |
||||||
|
b: function () { |
||||||
|
return this.comp.c + 1 |
||||||
|
}, |
||||||
|
c: function () { |
||||||
|
return this.comp.arr[1].n & 1; |
||||||
|
} |
||||||
|
}, |
||||||
|
actions: { |
||||||
|
run: function () { |
||||||
|
this.comp.name++; |
||||||
|
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 () { |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
BI.shortcut("demo.fix", Demo.Fix); |
||||||
|
}()); |
@ -0,0 +1,52 @@ |
|||||||
|
;(function () { |
||||||
|
var model = Fix.define({ |
||||||
|
name: "原始属性", |
||||||
|
arr: [{ |
||||||
|
n: 'a' |
||||||
|
}, { |
||||||
|
n: 0 |
||||||
|
}] |
||||||
|
}); |
||||||
|
|
||||||
|
Demo.Fix = BI.inherit(BI.Widget, { |
||||||
|
_store: function () { |
||||||
|
return model; |
||||||
|
}, |
||||||
|
watch: { |
||||||
|
"*.*.n": function () { |
||||||
|
debugger |
||||||
|
}, |
||||||
|
"arr.**": function () { |
||||||
|
debugger |
||||||
|
}, |
||||||
|
"arr.1.*": function () { |
||||||
|
this.button.setText(this.model.name + "-" + this.model.arr[1].n) |
||||||
|
} |
||||||
|
}, |
||||||
|
render: function () { |
||||||
|
var self = this; |
||||||
|
return { |
||||||
|
type: "bi.absolute", |
||||||
|
items: [{ |
||||||
|
el: { |
||||||
|
type: "bi.button", |
||||||
|
ref: function () { |
||||||
|
self.button = this; |
||||||
|
}, |
||||||
|
handler: function () { |
||||||
|
self.model.arr[0].n += 1; |
||||||
|
self.model.arr[1].n += 1; |
||||||
|
}, |
||||||
|
text: this.model.name + "-" + this.model.arr[1].n |
||||||
|
} |
||||||
|
}] |
||||||
|
} |
||||||
|
}, |
||||||
|
mounted: function () { |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
BI.shortcut("demo.fix5", Demo.Fix); |
||||||
|
}()); |
@ -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); |
||||||
|
}()); |
@ -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); |
||||||
|
}()); |
@ -0,0 +1,47 @@ |
|||||||
|
;(function () { |
||||||
|
function initWatch(vm, watch) { |
||||||
|
vm._watchers || (vm._watchers = []); |
||||||
|
for (var key in watch) { |
||||||
|
var handler = watch[key] |
||||||
|
if (BI.isArray(handler)) { |
||||||
|
for (var i = 0; i < handler.length; i++) { |
||||||
|
vm._watchers.push(createWatcher(vm, key, handler[i])) |
||||||
|
} |
||||||
|
} else { |
||||||
|
vm._watchers.push(createWatcher(vm, key, handler)) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function createWatcher(vm, keyOrFn, handler, options) { |
||||||
|
return Fix.watch(vm.model, keyOrFn, _.bind(handler, vm), options) |
||||||
|
} |
||||||
|
|
||||||
|
var _init = BI.Widget.prototype._init; |
||||||
|
BI.Widget.prototype._init = function () { |
||||||
|
if (window.Fix && this._store) { |
||||||
|
this.store = this._store(); |
||||||
|
if (this.store instanceof Fix.VM) { |
||||||
|
this.model = this.store.model; |
||||||
|
} else { |
||||||
|
this.model = this.store; |
||||||
|
} |
||||||
|
initWatch(this, this.watch); |
||||||
|
} |
||||||
|
_init.apply(this, arguments); |
||||||
|
}; |
||||||
|
|
||||||
|
var unMount = BI.Widget.prototype._unMount; |
||||||
|
BI.Widget.prototype._unMount = function () { |
||||||
|
unMount.apply(this, arguments); |
||||||
|
this.store && this.store.destroy(); |
||||||
|
BI.each(this._watchers, function (i, unwatches) { |
||||||
|
unwatches = BI.isArray(unwatches) ? unwatches : [unwatches]; |
||||||
|
BI.each(unwatches, function (j, unwatch) { |
||||||
|
unwatch(); |
||||||
|
}) |
||||||
|
}); |
||||||
|
this._watchers && (this._watchers = []); |
||||||
|
this.store && (this.store = null); |
||||||
|
} |
||||||
|
}()); |
Before Width: | Height: | Size: 335 B After Width: | Height: | Size: 289 B |
Before Width: | Height: | Size: 335 B After Width: | Height: | Size: 289 B |
Before Width: | Height: | Size: 602 B After Width: | Height: | Size: 497 B |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 894 B |
@ -1,2 +1,36 @@ |
|||||||
# rich_editor |
# rich_editor |
||||||
|
|
||||||
|
## 富文本编辑器,基类[BI.Widget](/core/widget.md) |
||||||
|
|
||||||
|
{% method %} |
||||||
|
[source](https://jsfiddle.net/fineui/e1jzxvq5/) |
||||||
|
|
||||||
|
{% common %} |
||||||
|
```javascript |
||||||
|
|
||||||
|
BI.createWidget({ |
||||||
|
type: "bi.rich_editor", |
||||||
|
width: 600, |
||||||
|
height: 400 |
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
``` |
||||||
|
|
||||||
|
{% endmethod %} |
||||||
|
|
||||||
|
## API |
||||||
|
##### 基础属性 |
||||||
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
||||||
|
| :------ |:------------- | :-----| :----|:---- |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 对外方法 |
||||||
|
| 名称 | 说明 | 回调参数 |
||||||
|
| :------ |:------------- | :----- |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- |
@ -1,2 +1,36 @@ |
|||||||
# editor_icon_check_combo |
# editor_icon_check_combo |
||||||
|
|
||||||
|
## 可以编辑trigger的TextValueCheckCombo,基类[BI.Widget](/core/widget.md) |
||||||
|
|
||||||
|
{% method %} |
||||||
|
[source](https://jsfiddle.net/fineui/w4gm7tfk/) |
||||||
|
|
||||||
|
{% common %} |
||||||
|
```javascript |
||||||
|
|
||||||
|
BI.createWidget({ |
||||||
|
type: "bi.editor_icon_check_combo", |
||||||
|
items: [] |
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
``` |
||||||
|
|
||||||
|
{% endmethod %} |
||||||
|
|
||||||
|
## API |
||||||
|
##### 基础属性 |
||||||
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
||||||
|
| :------ |:------------- | :-----| :----|:---- |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 对外方法 |
||||||
|
| 名称 | 说明 | 回调参数 |
||||||
|
| :------ |:------------- | :----- |
||||||
|
| populate | 刷新combo | items | |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- |
@ -1,2 +1,36 @@ |
|||||||
# text_value_check_combo |
# text_value_check_combo |
||||||
|
|
||||||
|
## 下拉列表项带√的TextValueCombo,基类[BI.Widget](/core/widget.md) |
||||||
|
|
||||||
|
{% method %} |
||||||
|
[source](https://jsfiddle.net/fineui/4dm7uu7w/) |
||||||
|
|
||||||
|
{% common %} |
||||||
|
```javascript |
||||||
|
|
||||||
|
BI.createWidget({ |
||||||
|
type: "bi.text_value_check_combo", |
||||||
|
items: [] |
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
``` |
||||||
|
|
||||||
|
{% endmethod %} |
||||||
|
|
||||||
|
## API |
||||||
|
##### 基础属性 |
||||||
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
||||||
|
| :------ |:------------- | :-----| :----|:---- |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 对外方法 |
||||||
|
| 名称 | 说明 | 回调参数 |
||||||
|
| :------ |:------------- | :----- |
||||||
|
| populate | 刷新combo | items | |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- |