From d265384f4c2d0cc21177179f0593f75fd1bd6367 Mon Sep 17 00:00:00 2001 From: guy Date: Sat, 28 Oct 2017 18:51:04 +0800 Subject: [PATCH] update --- .../canvasTable/large.table.canvas.js | 136 ------- demo/js/category/canvasTable/new.canvas.js | 228 ----------- demo/js/config/category.js | 4 - dist/demo.js | 368 +----------------- 4 files changed, 1 insertion(+), 735 deletions(-) delete mode 100644 demo/js/category/canvasTable/large.table.canvas.js delete mode 100644 demo/js/category/canvasTable/new.canvas.js diff --git a/demo/js/category/canvasTable/large.table.canvas.js b/demo/js/category/canvasTable/large.table.canvas.js deleted file mode 100644 index b08435de14..0000000000 --- a/demo/js/category/canvasTable/large.table.canvas.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/demo/js/category/canvasTable/new.canvas.js b/demo/js/category/canvasTable/new.canvas.js deleted file mode 100644 index da467c7e13..0000000000 --- a/demo/js/category/canvasTable/new.canvas.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/demo/js/config/category.js b/demo/js/config/category.js index 93c5ea7655..8d806c02ea 100644 --- a/demo/js/config/category.js +++ b/demo/js/config/category.js @@ -9,10 +9,6 @@ Demo.CATEGORY_CONFIG = [{ pId: 100000, text: "大表格", value: "demo.large_table" -}, { - pId: 100000, - text: "Canvas大表格", - value: "demo.canvas_table" }, { pId: 100000, text: "可以排序的树", diff --git a/dist/demo.js b/dist/demo.js index 3e2ce33272..eb002f8a2d 100644 --- a/dist/demo.js +++ b/dist/demo.js @@ -3929,369 +3929,7 @@ BI.shortcut("demo.select_text_trigger", Demo.Func);Demo.Func = BI.inherit(BI.Wid }) } }); -BI.shortcut("demo.text_trigger", Demo.Func);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);/** - * 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);/** +BI.shortcut("demo.text_trigger", Demo.Func);/** * guy * 二级树 * @class BI.PlatformLevelTree @@ -5435,10 +5073,6 @@ BI.shortcut("demo.value_chooser_pane", Demo.ValueChooserPane);Demo.ADDONS_CONFIG pId: 100000, text: "大表格", value: "demo.large_table" -}, { - pId: 100000, - text: "Canvas大表格", - value: "demo.canvas_table" }, { pId: 100000, text: "可以排序的树",