From 26354aea07d855859001cd9b15f81e27fe4cdd7f Mon Sep 17 00:00:00 2001 From: zhal <15900249928@163.com> Date: Fri, 8 Jul 2022 10:29:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scripts/diagraming/designer.core.debug.js | 9405 +---------------- .../scripts/diagraming/designer.ui.debug.js | 4578 +------- 2 files changed, 2 insertions(+), 13981 deletions(-) diff --git a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.core.debug.js b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.core.debug.js index 47db1b2d..1cea6614 100755 --- a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.core.debug.js +++ b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.core.debug.js @@ -1,9404 +1 @@ -Schema.init(true); -Schema.initMarkers(); -$(function() { - if (role == "trial") { - Designer.status = "demo" - } else { - if (role == "viewer") { - Designer.status = "readonly" - } else { - if (role == "running") { - Designer.status = "running" - } - } - } - Designer.init(); - UI.init(); - Dock.init(); - Navigator.init(); - if (Designer.status == "readonly") { - Designer.setReadonly(true); - $("#moreShapes").hide(); - Customize.init(); - return - } - if (Designer.status == "demo") { - UI.gettingStart() - } -}); -var Designer = { - config: { - panelItemWidth: 30, - panelItemHeight: 30, - pageMargin: 10, - anchorSize: 8, - rotaterSize: 9, - anchorColor: "#833", - selectorColor: "#833", - scale: 1 - }, - status: "", - initialize: { - initialized: false, - initLayout: function() { - $(window).bind("resize.designer", - function() { - showPainting(); - var b = $(window).height() - $("#designer_header").outerHeight() - $("#designer_footer").outerHeight(); - $(".layout").height(b); - if ($("#demo_signup").length) { - $("#designer_layout").height(b - $("#demo_signup").outerHeight()) - } - }); - $(window).trigger("resize.designer") - }, - initModel: function() { - Model.define = { - page: Utils.copy(Schema.pageDefaults), - elements: {} - }; - if (definition != undefined && definition.localAttribute != undefined) { - Model.define.localAttribute = definition.localAttribute - } else { - Model.define.localAttribute = {} - } - if (definition != undefined && definition.commonShapeConfig != undefined) { - Model.define.commonShapeConfig = definition.commonShapeConfig - } else { - Model.define.commonShapeConfig = {} - } - Model.persistence = { - page: Utils.copy(Schema.pageDefaults), - elements: {}, - localAttribute: {}, - commonShapeConfig: {} - } - }, - initCanvas: function() { - var q = Model.define.page.width.toScale(); - var v = Model.define.page.height.toScale(); - var B = Model.define.page.backgroundColor; - var s = Utils.getDarkerColor(B); - var A = Utils.getDarkestColor(B); - $("#designer_canvas").css({ - "background-color": "rgb(" + s + ")" - }); - var w = $("#designer_grids"); - w.attr({ - width: q, - height: v - }); - var h = w[0].getContext("2d"); - h.clearRect(0, 0, q, v); - var r = Model.define.page.padding.toScale(); - var y = q - r * 2; - var p = v - r * 2; - h.fillStyle = "rgb(" + B + ")"; - h.beginPath(); - h.rect(r, r, y, p); - h.fill(); - var x = Math.round(Model.define.page.gridSize.toScale()); - if (x < 10) { - x = 10 - } - if (Model.define.page.showGrid) { - h.translate(r, r); - h.lineWidth = 1; - h.save(); - var t = 0.5; - var u = 0; - while (t <= p) { - h.restore(); - if (u % 4 == 0) { - h.strokeStyle = "rgb(" + A + ")" - } else { - h.strokeStyle = "rgb(" + s + ")" - } - h.beginPath(); - h.moveTo(0, t); - h.lineTo(y, t); - t += x; - u++; - h.stroke() - } - t = 0.5; - u = 0; - while (t <= y) { - h.restore(); - if (u % 4 == 0) { - h.strokeStyle = "rgb(" + A + ")" - } else { - h.strokeStyle = "rgb(" + s + ")" - } - h.beginPath(); - h.moveTo(t, 0); - h.lineTo(t, p); - t += x; - u++; - h.stroke() - } - } - $("#canvas_container").css({ - width: q, - height: v, - padding: Designer.config.pageMargin - }); - if (!this.initialized) { - $("#designer_layout").scrollTop(Designer.config.pageMargin - 10); - $("#designer_layout").scrollLeft(Designer.config.pageMargin - 10) - } - var z = $("#bar_list_page").children("li[ac=set_page_showgrid]"); - z.menuitem("unselect"); - if (Model.define.page.showGrid) { - z.menuitem("select") - } - }, - initShapes: function() { - $("#shape_panel").empty(); - for (var o = 0; o < Schema.categories.length; o++) { - var n = Schema.categories[o]; - if (n.name == "standard") { - continue - } - $("#shape_panel").append("

" + n.text + "

") - } - $(".panel_title").unbind().bind("click", - function() { - $(this).parent().toggleClass("panel_collapsed") - }); - for (var s in Schema.shapes) { - var l = Schema.shapes[s]; - if (l.attribute.visible && l.category != "standard") { - if ((l.category == "process_bpmn2" || l.category == "process.bpmn2" || l.category == "bpmn") && checkRunningTimeShape(l)) { - continue; - } - if (!l.groupName) { - p(l) - } else { - var i = SchemaGroup.getGroup(l.groupName); - if (i[0] == s) { - p(l, l.groupName) - } - } - } - } - function p(b, d) { - b = Utils.copy(b); - var e = "
"; - var c = $(e).appendTo("#panel_" + b.category); - if (d) { - c.append("
") - } - var a = c.children()[0]; - c.bind("mouseenter", - function() { - if ($(this).hasClass("readonly")) { - return - } - var h = $("#shape_thumb"); - var title = b.title; - var category = b.category; - if (b.category == "bpmn") { - category = 'process_bpmn2'; - } - if (category == 'lane') { - category = methodId; - } - category = category.replace(/_/g,"."); - if (methodObjectDesc[category + '-' + b.name]) { - title += (':' + methodObjectDesc[category + '-' + b.name]); - } - h.children("div").text(title); - var j = h.children("canvas")[0].getContext("2d"); - var A = { - x: 0, - y: 0, - w: b.props.w, - h: b.props.h, - angle: b.props.angle - }; - var y = 160; - var k = 160; - j.clearRect(0, 0, y, k); - if (b.props.w >= b.props.h) { - if (b.props.w > y) { - A.w = y; - A.h = parseInt(b.props.h / b.props.w * A.w) - } - } else { - if (b.props.h > k) { - A.h = k; - A.w = parseInt(b.props.w / b.props.h * A.h) - } - } - h.children("canvas").attr({ - width: y + 20, - height: A.h + 20 - }); - h.show(); - b.props = A; - j.save(); - if (b.name != "text" && b.name != "umlText") { - j.globalAlpha = b.shapeStyle.alpha; - var f = (y + 20 - A.w) / 2; - var g = 10; - j.translate(f, g); - j.translate(A.w / 2, A.h / 2); - j.rotate(A.angle); - j.translate( - (A.w / 2), -(A.h / 2)); - Designer.painter.renderShapePath(j, b, true); - Designer.painter.renderMarkers(j, b, true) - } else { - j.translate(y / 2 + 10, A.h / 2 + 10); - j.textBaseline = "middle"; - j.textAlign = "center"; - var B = ""; - if (b.fontStyle.italic) { - B += "italic " - } else { - B += "normal " - } - if (b.fontStyle.bold) { - B += "bold " - } else { - B += "normal " - } - B += b.fontStyle.size + "pt "; - B += b.fontStyle.fontFamily; - j.font = B; - j.fillStyle = "rgb(" + b.fontStyle.color + ")"; - j.fillText(b.text, 0, 0) - } - j.restore(); - var z = c.offset().top - $("#designer_header").outerHeight() + c.height() / 2 - h.outerHeight() / 2; - if (z < 5) { - z = 5 - } else { - if (z + h.outerHeight() > $("#designer_viewport").height() - 5) { - z = $("#designer_viewport").height() - 5 - h.outerHeight() - } - } - h.css("top", z) - }).bind("mouseleave", - function() { - $("#shape_thumb").hide() - }); - Designer.painter.drawPanelItem(a, b.name) - } - r(); - function r() { - $(".panel_box").die().live("mousedown", - function(j) { - var c = $(this); - if (c.hasClass("readonly")) { - return - } - var h = c.attr("shapeName"); - var a = []; - Designer.op.changeState("creating_from_panel"); - var g = null; - var b = null; - var d = $("#designer_canvas"); - var f = t(h); - $("#designer").bind("mousemove.creating", - function(k) { - m(f, k) - }); - $("#canvas_container").bind("mousemove.create", - function(B) { - var D = Utils.getRelativePos(B.pageX, B.pageY, d); - if (g == null) { - g = q(h, D.x, D.y); - b = $("#" + g.id); - b.attr("class", "shape_box_creating") - } - b.css({ - left: D.x - b.width() / 2 + "px", - top: D.y - b.height() / 2 + "px", - "z-index": Model.orderList.length - }); - g.props.x = D.x.restoreScale() - g.props.w / 2; - g.props.y = D.y.restoreScale() - g.props.h / 2; - var G = g.props; - var H = Designer.op.snapLine(G, [g.id], true, g); - if (H.attach) { - g.attachTo = H.attach.id - } else { - delete g.attachTo - } - b.css({ - left: (g.props.x - 10).toScale() + "px", - top: (g.props.y - 10).toScale() + "px", - "z-index": Model.orderList.length - }); - a = Utils.getShapeAnchorInLinker(g); - Designer.op.hideLinkPoint(); - for (var C = 0; C < a.length; C++) { - var E = a[C]; - for (var F = 0; F < E.anchors.length; F++) { - var k = E.anchors[F]; - Designer.op.showLinkPoint(Utils.toScale(k)) - } - } - }); - var e = false; - $("#canvas_container").bind("mouseup.create", - function(k) { - e = true - }); - $(document).bind("mouseup.create", - function() { - $(this).unbind("mouseup.create"); - $("#designer").unbind("mousemove.creating"); - $("#creating_shape_container").hide(); - Designer.op.hideLinkPoint(); - Designer.op.hideSnapLine(); - $("#canvas_container").unbind("mouseup.create").unbind("mousemove.create"); - if (g != null) { - if (e == false) { - b.remove() - } else { - MessageSource.beginBatch(); - if (g.onCreated) { - var P = g.onCreated(); - if (P == false) { - b.remove(); - MessageSource.commit(); - return - } - } - b.attr("class", "shape_box"); - Designer.events.push("created", g); - Model.add(g); - var S = Utils.getShapeContext(g.id); - var Q = b.position(); - var K = 7; - for (var N = 0; N < a.length; N++) { - var W = a[N]; - var M = W.linker; - if (W.type == "line") { - var Y = Utils.copy(M); - var Z = Utils.copy(M); - Z.id = Utils.newId(); - if (W.anchors.length == 1) { - var O = W.anchors[0]; - var U = Utils.getPointAngle(g.id, O.x, O.y, K); - M.to = { - id: g.id, - x: O.x, - y: O.y, - angle: U - }; - Z.from = { - id: g.id, - x: O.x, - y: O.y, - angle: U - } - } else { - if (W.anchors.length == 2) { - var R = W.anchors[0]; - var T = W.anchors[1]; - var k = Utils.measureDistance(M.from, R); - var L = Utils.measureDistance(M.from, T); - var X, V; - if (k < L) { - X = R; - V = T - } else { - X = T; - V = R - } - var U = Utils.getPointAngle(g.id, X.x, X.y, K); - M.to = { - id: g.id, - x: X.x, - y: X.y, - angle: U - }; - U = Utils.getPointAngle(g.id, V.x, V.y, K); - Z.from = { - id: g.id, - x: V.x, - y: V.y, - angle: U - } - } - } - if (W.anchors.length <= 2) { - Designer.painter.renderLinker(M, true); - Model.update(M); - Designer.painter.renderLinker(Z, true); - Z.props.zindex = Model.maxZIndex + 1; - Model.add(Z); - Designer.events.push("linkerCreated", Z) - } - } else { - var O = W.anchors[0]; - var U = Utils.getPointAngle(g.id, O.x, O.y, K); - if (W.type == "from") { - M.from = { - id: g.id, - x: O.x, - y: O.y, - angle: U - } - } else { - M.to = { - id: g.id, - x: O.x, - y: O.y, - angle: U - } - } - Designer.painter.renderLinker(M, true); - Model.update(M) - } - } - Utils.unselect(); - Utils.selectShape(g.id); - MessageSource.commit(); - if (g.attribute.editable) { - Designer.op.editShapeText(g) - } - } - } - c.css({ - left: "0px", - top: "0px" - }); - Designer.op.resetState() - }) - }) - } - function t(a) { - var b = $("#creating_shape_canvas"); - var c = $("#creating_shape_container"); - if (b.length == 0) { - c = $("
").appendTo("#designer"); - b = $("").appendTo(c) - } - c.css({ - left: "0px", - top: "0px", - width: $(".panel_container").width(), - height: $("#shape_panel").outerHeight() - }); - Designer.painter.drawPanelItem(b[0], a); - return b - } - function m(b, a) { - $("#creating_shape_container").show(); - var c = Utils.getRelativePos(a.pageX, a.pageY, $("#creating_shape_container")); - b.css({ - left: c.x - Designer.config.panelItemWidth / 2, - top: c.y - Designer.config.panelItemHeight / 2 - }) - } - function q(g, e, f) { - var h = Utils.newId(); - var b = Schema.shapes[g]; - var c = e.restoreScale() - b.props.w / 2; - var d = f.restoreScale() - b.props.h / 2; - var a = Model.create(g, c, d); - Designer.painter.renderShape(a); - return a - } - } - }, - hotkey: { - init: function() { - var b = null; - $(document).unbind("keydown.hotkey").bind("keydown.hotkey", - function(n) { - if (n.ctrlKey && n.keyCode == 65) { - Designer.selectAll(); - n.preventDefault() - } else { - if (n.keyCode == 46 || n.keyCode == 8) { - Designer.op.removeShape(); - n.preventDefault() - } else { - if (n.ctrlKey && n.keyCode == 90) { - MessageSource.undo(); - n.preventDefault() - } else { - if (n.ctrlKey && n.keyCode == 89) { - MessageSource.redo(); - n.preventDefault() - } else { - if (n.ctrlKey && !n.shiftKey && n.keyCode == 67) { - Designer.clipboard.copy(); - n.preventDefault() - } else { - if (n.ctrlKey && n.keyCode == 88) { - Designer.clipboard.cut(); - n.preventDefault() - } else { - if (n.ctrlKey && n.keyCode == 86) { - Designer.clipboard.paste(); - n.preventDefault() - } else { - if (n.ctrlKey && n.keyCode == 68) { - Designer.clipboard.duplicate(); - n.preventDefault() - } else { - if (n.ctrlKey && n.shiftKey && n.keyCode == 66) { - Designer.clipboard.brush(); - n.preventDefault() - } else { - if (n.ctrlKey && n.keyCode == 190) { - Designer.zoomIn(); - n.preventDefault() - } else { - if (n.ctrlKey && n.keyCode == 188) { - Designer.zoomOut(); - n.preventDefault() - } else { - if (n.keyCode >= 37 && n.keyCode <= 40) { - if (b == null) { - var s = Utils.getSelected(); - var m = Utils.getFamilyShapes(s); - s = s.concat(m); - var q = Utils.getContainedShapes(s); - s = s.concat(q); - var r = Utils.getAttachedShapes(s); - s = s.concat(r); - var a = Utils.getOutlinkers(s); - b = s.concat(a) - } - if (b.length > 0) { - n.preventDefault(); - var t = 10; - if (n.ctrlKey) { - t = 1 - } - Utils.hideLinkerCursor(); - if (n.keyCode == 37) { - Designer.op.moveShape(b, { - x: -t, - y: 0 - }) - } else { - if (n.keyCode == 38) { - Designer.op.moveShape(b, { - x: 0, - y: -t - }) - } else { - if (n.keyCode == 39) { - Designer.op.moveShape(b, { - x: t, - y: 0 - }) - } else { - if (n.keyCode == 40) { - Designer.op.moveShape(b, { - x: 0, - y: t - }) - } - } - } - } - $(document).unbind("keyup.moveshape").bind("keyup.moveshape", - function() { - Model.updateMulti(b); - b = null; - $(document).unbind("keyup.moveshape"); - Designer.op.hideTip(); - Utils.showLinkerCursor() - }) - } - } else { - if (n.keyCode == 221 && n.ctrlKey) { - var e = "front"; - if (n.shiftKey) { - e = "forward" - } - Designer.layerShapes(e) - } else { - if (n.keyCode == 219 && n.ctrlKey) { - var e = "back"; - if (n.shiftKey) { - e = "backward" - } - Designer.layerShapes(e) - } else { - if (n.keyCode == 71 && n.ctrlKey) { - n.preventDefault(); - if (n.shiftKey) { - Designer.ungroup() - } else { - Designer.group() - } - } else { - if (n.keyCode == 76 && n.ctrlKey) { - n.preventDefault(); - if (n.shiftKey) { - Designer.unlockShapes() - } else { - Designer.lockShapes() - } - } else { - if (n.keyCode == 18) { - Designer.op.changeState("drag_canvas") - } else { - if (n.keyCode == 27) { - if (!Designer.op.state) { - Utils.unselect(); - $(".menu.list").hide(); - $(".menu").hide(); - $(".color_picker").hide() - } else { - if (Designer.op.state == "creating_free_text" || Designer.op.state == "creating_free_linker") { - Designer.op.resetState() - } - } - } else { - if (n.keyCode == 84 && !n.ctrlKey) { - $(".menu.list").hide(); - Designer.op.changeState("creating_free_text") - } else { - if (n.keyCode == 73 && !n.ctrlKey) { - $(".menu.list").hide(); - UI.showImageSelect(function(c, d, f) { - UI.insertImage(c, d, f) - }); - $("#designer_contextmenu").hide() - } else { - if (n.keyCode == 76 && !n.ctrlKey) { - $(".menu.list").hide(); - Designer.op.changeState("creating_free_linker"); - $("#designer_contextmenu").hide() - } else { - if (n.keyCode == 66 && n.ctrlKey) { - var o = Utils.getSelectedIds(); - if (o.length > 0) { - var p = Model.getShapeById(o[0]); - Designer.setFontStyle({ - bold: !p.fontStyle.bold - }); - UI.update() - } - } else { - if (n.keyCode == 73 && n.ctrlKey) { - var o = Utils.getSelectedIds(); - if (o.length > 0) { - var p = Model.getShapeById(o[0]); - Designer.setFontStyle({ - italic: !p.fontStyle.italic - }); - UI.update() - } - } else { - if (n.keyCode == 85 && n.ctrlKey) { - var o = Utils.getSelectedIds(); - if (o.length > 0) { - var p = Model.getShapeById(o[0]); - Designer.setFontStyle({ - underline: !p.fontStyle.underline - }); - UI.update() - } - n.preventDefault() - } else { - if (n.keyCode == 32 && !n.ctrlKey) { - var o = Utils.getSelectedIds(); - if (o.length == 1) { - var p = Model.getShapeById(o[0]); - Designer.op.editShapeText(p) - } - n.preventDefault() - } else { - if (n.keyCode == 121) { - n.preventDefault(); - Dock.enterPresentation() - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - }); - $("input,textarea,select").die().live("keydown.hotkey", - function(a) { - a.stopPropagation() - }) - }, - cancel: function() { - $(document).unbind("keydown.hotkey") - } - }, - contextMenu: { - init: function() { - $("#designer_contextmenu").unbind("mousedown").bind("mousedown", - function(b) { - b.stopPropagation() - }); - $("#designer_contextmenu").find("li:not(.devider)").unbind("click").bind("click", - function() { - var b = $(this); - if (!b.menuitem("isDisabled") && b.children(".extend_menu").length == 0) { - Designer.contextMenu.execAction(b); - Designer.contextMenu.hide() - } - }); - $("#canvas_container").unbind("contextmenu").bind("contextmenu", - function(d) { - d.preventDefault(); - var e = $("#designer_canvas"); - var f = Utils.getRelativePos(d.pageX, d.pageY, e); - Designer.contextMenu.show(f.x, f.y) - }) - }, - destroy: function() { - $("#canvas_container").unbind("contextmenu"); - this.hide() - }, - menuPos: { - x: 0, - y: 0, - shape: null - }, - show: function(k, l) { - this.menuPos.x = k; - this.menuPos.y = l; - var p = $("#designer_contextmenu"); - var r = Utils.getShapeByPosition(k, l, false); - p.children().hide(); - p.children("li[ac=selectall]").show(); - p.children(".devi_selectall").show(); - p.children("li[ac=drawline]").show(); - var q = Designer.clipboard.elements.length; - if (r == null) { - if (q > 0) { - p.children("li[ac=paste]").show(); - p.children(".devi_clip").show() - } - } else { - var n = r.shape; - this.menuPos.shape = n; - if (n.locked) { - if (q > 0) { - p.children("li[ac=paste]").show(); - p.children(".devi_clip").show() - } - p.children("li[ac=unlock]").show(); - p.children(".devi_shape").show() - } else { - p.children("li[ac=cut]").show(); - p.children("li[ac=copy]").show(); - p.children("li[ac=duplicate]").show(); - if (q > 0) { - p.children("li[ac=paste]").show() - } - p.children(".devi_clip").show(); - p.children("li[ac=front]").show(); - p.children("li[ac=back]").show(); - p.children("li[ac=lock]").show(); - var m = Utils.getSelectedIds(); - var o = m.length; - if (o >= 2) { - p.children("li[ac=group]").show(); - $("#ctxmenu_align").show() - } - var j = Utils.getSelectedGroups().length; - if (j >= 1) { - p.children("li[ac=ungroup]").show() - } - p.children(".devi_shape").show(); - if (o == 1 && n.name != "linker" && n.link) { - p.children("li[ac=changelink]").show() - } - if (n.name == "linker" || n.attribute.editable) { - p.children("li[ac=edit]").show() - } - p.children("li[ac=delete]").show(); - p.children(".devi_del").show() - } - } - p.css({ - display: "block", - "z-index": Model.orderList.length + 3, - left: k, - top: l - }); - $(document).bind("mousedown.ctxmenu", - function() { - Designer.contextMenu.hide() - }) - }, - hide: function() { - $("#designer_contextmenu").hide(); - $(document).unbind("mousedown.ctxmenu") - }, - execAction: function(e) { - var d = e.attr("ac"); - if (d == "cut") { - Designer.clipboard.cut() - } else { - if (d == "copy") { - Designer.clipboard.copy() - } else { - if (d == "paste") { - Designer.clipboard.paste(this.menuPos.x, this.menuPos.y) - } else { - if (d == "duplicate") { - Designer.clipboard.duplicate() - } else { - if (d == "front") { - Designer.layerShapes("front") - } else { - if (d == "back") { - Designer.layerShapes("back") - } else { - if (d == "lock") { - Designer.lockShapes() - } else { - if (d == "unlock") { - Designer.unlockShapes() - } else { - if (d == "group") { - Designer.group() - } else { - if (d == "ungroup") { - Designer.ungroup() - } else { - if (d == "align_shape") { - var f = e.attr("al"); - Designer.alignShapes(f) - } else { - if (d == "edit") { - Designer.op.editShapeText(this.menuPos.shape) - } else { - if (d == "delete") { - Designer.op.removeShape() - } else { - if (d == "selectall") { - Designer.selectAll() - } else { - if (d == "drawline") { - Designer.op.changeState("creating_free_linker") - } else { - if (d == "changelink") { - UI.showInsertLink() - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - }, - init: function() { - this.initialize.initLayout(); - this.initialize.initModel(); - this.initialize.initCanvas(); - this.initialize.initShapes(); - this.hotkey.init(); - this.contextMenu.init(); - Designer.op.init(); - this.initialize.initialized = true; - Designer.events.push("initialized"); - $("#designer_layout").on("scroll", - function() { - $(document).trigger("mouseup.multiselect") - }) - }, - op: { - init: function() { - var c = $("#designer_canvas"); - var d = $("#canvas_container"); - d.unbind("mousemove.operate").bind("mousemove.operate", - function(a) { - if (Designer.op.state != null) { - return - } - Designer.op.destroy(); - var b = Utils.getRelativePos(a.pageX, a.pageY, c); - var j = Utils.getShapeByPosition(b.x, b.y); - if (j != null) { - if (j.type == "dataAttribute") {} else { - if (j.type == "linker") { - d.css("cursor", "pointer"); - Designer.op.shapeSelectable(j.shape); - var h = j.shape; - var i = j.pointIndex; - if (h.linkerType == "broken" && i > 1 && i <= h.points.length) { - Designer.op.brokenLinkerChangable(h, i - 1) - } else { - if (h.from.id == null && h.to.id == null) { - d.css("cursor", "move"); - Designer.op.shapeDraggable() - } - } - Designer.op.linkerEditable(h) - } else { - if (j.type == "linker_point") { - d.css("cursor", "move"); - Designer.op.shapeSelectable(j.shape); - Designer.op.linkerDraggable(j.shape, j.point); - Designer.op.linkerEditable(j.shape) - } else { - if (j.type == "linker_text") { - d.css("cursor", "text"); - Designer.op.shapeSelectable(j.shape); - Designer.op.linkerEditable(j.shape) - } else { - if (j.type == "shape") { - if (j.shape.locked) { - d.css("cursor", "default"); - Designer.op.shapeSelectable(j.shape) - } else { - d.css("cursor", "move"); - Designer.op.shapeSelectable(j.shape); - Designer.op.shapeEditable(j.shape); - Designer.op.shapeDraggable(); - if (j.shape.link) {} - } - } else { - d.css("cursor", "crosshair"); - Designer.op.shapeSelectable(j.shape); - Designer.op.shapeLinkable(j.shape, j.linkPoint) - } - if (j.shape.parent) { - Utils.showAnchors(Model.getShapeById(j.shape.parent)) - } else { - Utils.showAnchors(j.shape) - } - } - } - } - } - } else { - d.css("cursor", "default"); - Designer.op.shapeMultiSelectable() - } - }) - }, - cancel: function() { - $("#canvas_container").unbind("mousemove.operate").css("cursor", "default"); - this.destroy() - }, - destroy: function() { - $("#designer_canvas").unbind("mousedown.drag").unbind("dblclick.edit").unbind("mousedown.draglinker").unbind("mousedown.select").unbind("mousedown.brokenLinker").unbind("dblclick.edit_linker"); - $("#canvas_container").unbind("mousedown.link").unbind("mousedown.create_text").unbind("mousedown.drag_canvas"); - $("#designer_layout").unbind("mousedown.multiselect"); - Utils.hideAnchors(); - $("#link_spot").hide() - }, - state: null, - changeState: function(b) { - this.state = b; - if (b == "creating_free_text") { - this.destroy(); - $("#canvas_container").css("cursor", "crosshair"); - this.textCreatable() - } else { - if (b == "creating_free_linker") { - this.destroy(); - $("#canvas_container").css("cursor", "crosshair"); - this.shapeLinkable() - } else { - if (b == "drag_canvas") { - this.destroy(); - this.canvasDraggable() - } else { - if (b == "changing_curve") { - this.destroy() - } - } - } - } - }, - resetState: function() { - this.state = null; - $("#canvas_container").css("cursor", "default") - }, - shapeSelectable: function(d) { - var c = $("#designer_canvas"); - c.bind("mousedown.select", - function(b) { - Designer.op.changeState("seelcting_shapes"); - var a = d.id; - var f = []; - if (b.ctrlKey) { - var f = Utils.getSelectedIds(); - if (Utils.isSelected(a)) { - Utils.removeFromArray(f, a) - } else { - f.push(a) - } - Utils.unselect(); - if (f.length > 0) { - Utils.selectShape(f) - } - } else { - if (Utils.selectIds.indexOf(a) < 0) { - Utils.unselect(); - Utils.selectShape(a) - } - } - $(document).bind("mouseup.select", - function() { - Designer.op.resetState(); - c.unbind("mousedown.select"); - $(document).unbind("mouseup.select") - }) - }) - }, - shapeDraggable: function() { - var c = $("#designer_canvas"); - var d = $("#canvas_container"); - c.bind("mousedown.drag", - function(b) { - Utils.hideLinkerCursor(); - Utils.hideLinkerControls(); - Designer.op.changeState("dragging"); - var x = Utils.getRelativePos(b.pageX, b.pageY, c); - var u = Utils.getSelected(); - var w = true; - if (u.length == 1 && u[0].name == "linker") { - w = false - } - var z = null; - if (w) { - z = Utils.getShapesBounding(u) - } - var i = Utils.getFamilyShapes(u); - u = u.concat(i); - var r = Utils.getContainedShapes(u); - u = u.concat(r); - var s = Utils.getAttachedShapes(u); - u = u.concat(s); - var y = []; - if (w) { - for (var t = 0; t < u.length; t++) { - var q = u[t]; - if (q == undefined) { - continue - } - if (q.name == "linker") { - if (q.from.id && y.indexOf(q.from.id) < 0) { - y.push(q.from.id) - } - if (q.to.id && y.indexOf(q.to.id) < 0) { - y.push(q.to.id) - } - } - if (y.indexOf(q.id) < 0) { - y.push(q.id) - } - } - } - var v = u; - var a = Utils.getOutlinkers(u); - u = u.concat(a); - d.bind("mousemove.drag", - function(j) { - $("#link_spot").hide(); - var f = Utils.getRelativePos(j.pageX, j.pageY, c); - var g = { - x: f.x - x.x, - y: f.y - x.y - }; - if (w) { - var e = Utils.copy(z); - e.x += g.x; - e.y += g.y; - var h = Designer.op.snapLine(e, y); - g = { - x: e.x - z.x, - y: e.y - z.y - }; - f = { - x: x.x + g.x, - y: x.y + g.y - }; - z.x += g.x; - z.y += g.y; - if (v.length == 1 && v[0].groupName == "boundaryEvent") { - if (h.attach) { - v[0].attachTo = h.attach.id - } else { - delete u[0].attachTo - } - } - } - if (g.x == 0 && g.y == 0) { - return - } - Designer.op.moveShape(u, g); - x = f; - $(document).unbind("mouseup.drop").bind("mouseup.drop", - function() { - Model.updateMulti(u); - $(document).unbind("mouseup.drop") - }) - }); - $(document).bind("mouseup.drag", - function() { - Designer.op.resetState(); - d.unbind("mousemove.drag"); - c.unbind("mousedown.drag"); - $(document).unbind("mouseup.drag"); - Designer.op.hideTip(); - Designer.op.hideSnapLine(); - Utils.showLinkerCursor(); - Utils.showLinkerControls(); - var selectedShape = Utils.getSelected()[0]; - if (selectedShape) { - var shapePosition = selectedShape.props; - var pageSize = Model.define.page; - if (shapePosition.x + shapePosition.w > pageSize.width - pageSize.padding){ - Designer.setPageStyle({ - width: shapePosition.x + shapePosition.w + pageSize.padding + 30 - }); - $("#page_size_w").spinner('value',shapePosition.x + shapePosition.w + pageSize.padding + 30); - } - if (shapePosition.y + shapePosition.h > pageSize.height - pageSize.padding){ - Designer.setPageStyle({ - height: shapePosition.y + shapePosition.h + pageSize.padding + 30 - }); - $("#page_size_h").spinner('value',shapePosition.x + shapePosition.w + pageSize.padding + 30) - } - } - if (isAutoSave == "0") { - $("#saving_tip").css("color", "rgb(255, 0, 0)"); - $("#saving_tip").text("文件已修改,未保存"); - } - }) - }) - }, - shapeResizable: function() { - $(".shape_controller").bind("mousedown", - function(ab) { - if (!isAdmin && isCustomDefine == "1") { - var ae = Utils.getSelected(); - var P = true; - for (var p = 0; p < ae.length; p++) { - var V = ae[p].name; - var i = Schema.shapes[V]; - if (i.resizeable == "0") { - return - } - } - } - Utils.hideLinkerCursor(); - if ($("#shape_text_edit").length) { - $("#shape_text_edit").trigger("blur") - } - var S = $("#canvas_container"); - var Y = $("#designer_canvas"); - ab.stopPropagation(); - var D = Utils.getRelativePos(ab.pageX, ab.pageY, Y); - var Q = $(this); - Designer.op.changeState("resizing"); - var U = Utils.getSelectedIds(); - var K = Utils.getSelected(); - var M; - if (U.length == 1) { - var aa = Model.getShapeById(U[0]); - M = Utils.copy(aa.props) - } else { - M = Utils.getControlBox(U); - M.angle = 0 - } - var C = { - x: M.x + M.w / 2, - y: M.y + M.h / 2 - }; - var N = Q.attr("resizeDir"); - var E = {}; - if (N.indexOf("l") >= 0) { - E.x = M.x + M.w - } else { - if (N.indexOf("r") >= 0) { - E.x = M.x - } else { - E.x = M.x + M.w / 2 - } - } - if (N.indexOf("t") >= 0) { - E.y = M.y + M.h - } else { - if (N.indexOf("b") >= 0) { - E.y = M.y - } else { - E.y = M.y + M.h / 2 - } - } - E = Utils.getRotated(C, E, M.angle); - function G(a, b) { - if (a.id == null) { - if (b) { - return { - type: "box", - x: (a.x - M.x) / M.w, - y: (a.y - M.y) / M.h - } - } else { - return { - type: "fixed" - } - } - } else { - if (Utils.isSelected(a.id)) { - var e = Model.getShapeById(a.id); - var d = { - x: e.props.x + e.props.w / 2, - y: e.props.y + e.props.h / 2 - }; - var c = Utils.getRotated(d, a, -e.props.angle); - return { - type: "shape", - x: (c.x - e.props.x) / e.props.w, - y: (c.y - e.props.y) / e.props.h - } - } else { - return { - type: "fixed" - } - } - } - } - var W = []; - var ac = {}; - var Z = []; - var L = Utils.getAttachedShapes(K); - K = K.concat(L); - var J = []; - for (var H = 0; H < K.length; H++) { - var aa = K[H]; - J.push(aa.id); - if (aa.parent) { - J.push(aa.parent) - } - if (aa.name == "linker") { - if (Z.indexOf(aa.id) == -1) { - Z.push(aa.id) - } - } else { - W.push(aa); - if (aa.attachTo && !Utils.isSelected(aa.id)) { - ac[aa.id] = { - type: "attached", - x: (aa.props.x + aa.props.w / 2 - M.x) / M.w, - y: (aa.props.y + aa.props.h / 2 - M.y) / M.h - } - } else { - ac[aa.id] = { - x: (aa.props.x - M.x) / M.w, - y: (aa.props.y - M.y) / M.h, - w: aa.props.w / M.w, - h: aa.props.h / M.h - } - } - var I = Model.getShapeLinkers(aa.id); - if (I && I.length > 0) { - for (var T = 0; T < I.length; T++) { - var O = I[T]; - if (Z.indexOf(O) == -1) { - Z.push(O) - } - } - } - } - } - for (var H = 0; H < Z.length; H++) { - var O = Z[H]; - var R = Model.getShapeById(O); - W.push(R); - var K = Utils.isSelected(O); - ac[R.id] = { - from: G(R.from, K), - to: G(R.to, K) - } - } - var X = Q.css("cursor"); - S.css("cursor", X); - var F = []; - var ad = { - w: 20, - h: 20 - }; - Designer.events.push("beforeResize", { - minSize: ad, - shapes: W, - dir: N - }); - S.bind("mousemove.resize", - function(a) { - F = []; - var t = Utils.getRelativePos(a.pageX, a.pageY, Y); - t = Utils.restoreScale(t); - var k = Utils.getRotated(E, t, -M.angle); - var w = Utils.copy(M); - if (N.indexOf("r") >= 0) { - w.w = k.x - E.x - } else { - if (N.indexOf("l") >= 0) { - w.w = E.x - k.x - } - } - if (N.indexOf("b") >= 0) { - w.h = k.y - E.y - } else { - if (N.indexOf("t") >= 0) { - w.h = E.y - k.y - } - } - if (a.ctrlKey && N.length == 2) { - if (M.w >= M.h) { - w.h = M.h / M.w * w.w; - if (w.h < ad.h) { - w.h = ad.h; - w.w = M.w / M.h * w.h - } - } else { - w.w = M.w / M.h * w.h; - if (w.w < ad.w) { - w.w = ad.w; - w.h = M.h / M.w * w.w - } - } - } else { - if (w.w < ad.w) { - w.w = ad.w - } - if (w.h < ad.h) { - w.h = ad.h - } - } - var d = {}; - if (N.indexOf("r") >= 0) { - d.x = E.x + w.w - } else { - if (N.indexOf("l") >= 0) { - d.x = E.x - w.w - } else { - d.x = E.x - } - } - if (N.indexOf("b") >= 0) { - d.y = E.y + w.h - } else { - if (N.indexOf("t") >= 0) { - d.y = E.y - w.h - } else { - d.y = E.y - } - } - var o = Utils.getRotated(E, d, M.angle); - var m = { - x: 0.5 * E.x + 0.5 * o.x, - y: 0.5 * E.y + 0.5 * o.y - }; - var f = Utils.getRotated(m, E, -M.angle); - if (N.indexOf("r") >= 0) { - w.x = f.x - } else { - if (N.indexOf("l") >= 0) { - w.x = f.x - w.w - } else { - w.x = f.x - w.w / 2 - } - } - if (N.indexOf("b") >= 0) { - w.y = f.y - } else { - if (N.indexOf("t") >= 0) { - w.y = f.y - w.h - } else { - w.y = f.y - w.h / 2 - } - } - if (w.angle == 0) { - var y = W[0]; - var h = Designer.op.snapResizeLine(w, J, N) - } - Utils.removeAnchors(); - for (var e = 0; e < W.length; e++) { - var u = W[e]; - var j = ac[u.id]; - if (u.name == "linker") { - if (j.from.type == "box") { - u.from.x = w.x + w.w * j.from.x; - u.from.y = w.y + w.h * j.from.y - } else { - if (j.from.type == "shape") { - var c = Model.getShapeById(u.from.id); - var g = { - x: c.props.x + c.props.w * j.from.x, - y: c.props.y + c.props.h * j.from.y - }; - var b = { - x: c.props.x + c.props.w / 2, - y: c.props.y + c.props.h / 2 - }; - var s = Utils.getRotated(b, g, c.props.angle); - u.from.x = s.x; - u.from.y = s.y - } - } - if (j.to.type == "box") { - u.to.x = w.x + w.w * j.to.x; - u.to.y = w.y + w.h * j.to.y - } else { - if (j.to.type == "shape") { - var c = Model.getShapeById(u.to.id); - var g = { - x: c.props.x + c.props.w * j.to.x, - y: c.props.y + c.props.h * j.to.y - }; - var b = { - x: c.props.x + c.props.w / 2, - y: c.props.y + c.props.h / 2 - }; - var s = Utils.getRotated(b, g, c.props.angle); - u.to.x = s.x; - u.to.y = s.y - } - } - Designer.painter.renderLinker(u, true) - } else { - if (j.type == "attached") { - u.props.x = w.x + w.w * j.x - u.props.w / 2; - u.props.y = w.y + w.h * j.y - u.props.h / 2 - } else { - var x = Utils.copy(u.props); - u.props.x = w.x + w.w * j.x; - u.props.y = w.y + w.h * j.y; - u.props.w = w.w * j.w; - u.props.h = w.h * j.h; - var v = Model.getShapeById(u.id).props; - v.x = w.x + w.w * j.x; - v.y = w.y + w.h * j.y; - v.w = w.w * j.w; - v.h = w.h * j.h; - var q = { - x: u.props.x - x.x, - y: u.props.y - x.y, - w: u.props.w - x.w, - h: u.props.h - x.h - }; - var l = { - shape: u, - offset: q, - dir: N - }; - var n = Designer.events.push("resizing", l); - if (n) { - F = F.concat(n) - } - } - Designer.painter.renderShape(u); - Utils.showAnchors(u) - } - } - Designer.painter.drawControls(U); - var r = "W: " + Math.round(w.w) + "  H: " + Math.round(w.h); - if (w.x != M.x) { - r = "X: " + Math.round(w.x) + "  Y: " + Math.round(w.y) + "
" + r - } - Designer.op.showTip(r); - $(document).unbind("mouseup.resize_ok").bind("mouseup.resize_ok", - function() { - if (F.length > 0) { - W = W.concat(F) - } - Model.updateMulti(W); - $(document).unbind("mouseup.resize_ok") - }) - }); - $(document).bind("mouseup.resize", - function() { - S.css("cursor", "default"); - Designer.op.resetState(); - S.unbind("mousemove.resize"); - $(document).unbind("mouseup.resize"); - var selectedShape = Utils.getSelected()[0]; - if (selectedShape) { - var shapePosition = selectedShape.props; - var pageSize = Model.define.page; - if (shapePosition.x + shapePosition.w > pageSize.width - pageSize.padding){ - Designer.setPageStyle({ - width: shapePosition.x + shapePosition.w + pageSize.padding + 10 - }); - } - if (shapePosition.y + shapePosition.h > pageSize.height - pageSize.padding){ - Designer.setPageStyle({ - height: shapePosition.y + shapePosition.h + pageSize.padding + 10 - }); - } - } - Designer.op.hideTip(); - Utils.showLinkerCursor(); - Designer.op.hideSnapLine() - }) - }) - }, - shapeRotatable: function() { - $(".shape_rotater").bind("mousemove", - function(i) { - var j = $(this); - var g = i.pageX - j.offset().left; - var h = i.pageY - j.offset().top; - var e = j[0].getContext("2d"); - j.unbind("mousedown"); - j.removeClass("rotate_enable"); - if (e.isPointInPath(g, h)) { - j.addClass("rotate_enable"); - j.bind("mousedown", - function(b) { - Utils.hideLinkerCursor(); - if ($("#shape_text_edit").length) { - $("#shape_text_edit").trigger("blur") - } - b.stopPropagation(); - Designer.op.changeState("rotating"); - var r = Utils.getSelectedIds(); - var c; - var s; - if (r.length == 1) { - var f = Model.getShapeById(r[0]); - c = f.props; - s = f.props.angle - } else { - c = Utils.getControlBox(r); - s = 0 - } - var x = { - x: c.x + c.w / 2, - y: c.y + c.h / 2 - }; - var d = Utils.toScale(x); - var w = $("#designer_canvas"); - var u = Utils.getSelected(); - var t = Utils.getAttachedShapes(u); - u = u.concat(t); - var a = Utils.getOutlinkers(u); - u = u.concat(a); - var v = s; - $(document).bind("mousemove.rotate", - function(l) { - var m = Utils.getRelativePos(l.pageX, l.pageY, w); - var H = Math.atan(Math.abs(m.x - d.x) / Math.abs(d.y - m.y)); - if (m.x >= d.x && m.y >= d.y) { - H = Math.PI - H - } else { - if (m.x <= d.x && m.y >= d.y) { - H = Math.PI + H - } else { - if (m.x <= d.x && m.y <= d.y) { - H = Math.PI * 2 - H - } - } - } - H = H % (Math.PI * 2); - var k = Math.PI / 36; - var o = Math.round(H / k); - H = k * o; - if (H == v) { - return - } - v = H; - Designer.op.showTip(o * 5 % 360 + "°"); - Designer.painter.rotateControls(c, H); - Utils.removeAnchors(); - var L = H - s; - for (var G = 0; G < u.length; G++) { - var q = u[G]; - var I = Model.getPersistenceById(q.id); - if (q.name != "linker") { - q.props.angle = Math.abs((L + I.props.angle) % (Math.PI * 2)); - var F = { - x: I.props.x + I.props.w / 2, - y: I.props.y + I.props.h / 2 - }; - var n = Utils.getRotated(x, F, L); - q.props.x = n.x - q.props.w / 2; - q.props.y = n.y - q.props.h / 2; - Designer.painter.renderShape(q); - Utils.showAnchors(q) - } else { - var p = false; - if ((Utils.isSelected(q.id) && q.from.id == null) || Utils.isSelected(q.from.id)) { - var K = Utils.getRotated(x, I.from, L); - q.from.x = K.x; - q.from.y = K.y; - if (q.from.angle != null) { - q.from.angle = Math.abs((I.from.angle + L) % (Math.PI * 2)) - } - p = true - } - var J = false; - if ((Utils.isSelected(q.id) && q.to.id == null) || Utils.isSelected(q.to.id)) { - var K = Utils.getRotated(x, I.to, L); - q.to.x = K.x; - q.to.y = K.y; - if (q.to.angle != null) { - q.to.angle = Math.abs((I.to.angle + L) % (Math.PI * 2)) - } - J = true - } - if (p || J) { - Designer.painter.renderLinker(q, true) - } - } - } - }).bind("mouseup.rotate", - function() { - $(document).unbind("mousemove.rotate").unbind("mouseup.rotate"); - Designer.op.resetState(); - Model.updateMulti(u); - Designer.painter.drawControls(r); - Designer.op.hideTip(); - Utils.showLinkerCursor() - }) - }) - } else { - j.removeClass("rotate_enable"); - j.unbind("mousedown") - } - }) - }, - groupShapeChangable: function() { - $(".change_shape_icon").bind("mousedown", - function(l) { - l.stopPropagation(); - var i = Utils.getSelected()[0]; - var j = i.groupName; - var m = $(this).parent(); - var k = m.position(); - var n = k.left + m.width(); - var e = k.top + m.height() + 10; - Designer.op.groupDashboard(j, n, e, - function(c) { - if (i.name != c) { - var b = Designer.events.push("shapeChanged", { - shape: i, - name: c - }); - var b1 = Utils.copy(i); //保留源节点信息(AttributesJsonArray) - var b2 = Utils.copy(i); //重新保留源节点信息(AttributesJsonArray) - Model.changeShape(i, c); //重画节点后会把节点信息抹去 - //将源节点b2内的AttributesJsonArray加入默认属性,并且替换源节点有值并且为目标节点默认属性的属性。 - for(var x = 0; x < b2.dataAttributes.length; x++) { - var b2x = b2.dataAttributes[x]; - if(b2x.attributesJsonArray) { - var attributesJsonArray = b2x.attributesJsonArray.splice(0); //源节点的属性 - //加入默认属性 - if (Model.define.localAttribute != undefined && Model.define.localAttribute[c] != undefined && Model.define.localAttribute[c] != null && Model.define.localAttribute[c].length > 0) { - for(var b2xi in Model.define.localAttribute[c]) { - b2x.attributesJsonArray.push(Utils.copy(Model.define.localAttribute[c][b2xi])); - } - } - //替换源节点有值的属性 - for(var pj = 0; pj < attributesJsonArray.length; pj++) { - var hasValue = ( attributesJsonArray[pj].value || attributesJsonArray[pj].value === false ) && attributesJsonArray[pj].value !==[]; - if(attributesJsonArray[pj] && attributesJsonArray[pj].id && hasValue) { - var flag = false; - for(var b2xj = 0; b2xj < b2x.attributesJsonArray.length; b2xj++) { - if(b2x.attributesJsonArray[b2xj] && b2x.attributesJsonArray[b2xj].id == attributesJsonArray[pj].id) { - b2x.attributesJsonArray[b2xj] = attributesJsonArray[pj]; - flag = true; - break; - } - } - } - } - } - } - i.dataAttributes = b2.dataAttributes; //重新加入默认属性并且加入源节点带值的属性 - var a = [i]; - if (b && b.length > 0) { - a = a.concat(b) - } - Model.updateMulti(a) - } - }) - }) - }, - shapeMultiSelectable: function() { - var d = $("#designer_canvas"); - var c = $("#designer_layout"); - c.unbind("mousedown.multiselect").bind("mousedown.multiselect", - function(a) { - var b = null; - if (!a.ctrlKey) { - Utils.unselect() - } - var f = Utils.getRelativePos(a.pageX, a.pageY, d); - Designer.op.changeState("multi_selecting"); - c.bind("mousemove.multiselect", - function(i) { - if (b == null) { - b = $("
").appendTo(d) - } - var j = Utils.getRelativePos(i.pageX, i.pageY, d); - var e = { - "z-index": Model.orderList.length, - left: j.x, - top: j.y - }; - if (j.x > f.x) { - e.left = f.x - } - if (j.y > f.y) { - e.top = f.y - } - e.width = Math.abs(j.x - f.x); - e.height = Math.abs(j.y - f.y); - b.css(e) - }); - $(document).unbind("mouseup.multiselect").bind("mouseup.multiselect", - function(j) { - if (b != null) { - var l = { - x: b.position().left.restoreScale(), - y: b.position().top.restoreScale(), - w: b.width().restoreScale(), - h: b.height().restoreScale() - }; - var e = Utils.getShapesByRange(l); - if (j.ctrlKey) { - var k = Utils.getSelectedIds(); - Utils.mergeArray(e, k) - } - Utils.unselect(); - Utils.selectShape(e); - b.remove() - } - Designer.op.resetState(); - $(document).unbind("mouseup.multiselect"); - c.unbind("mousemove.multiselect") - }); - c.unbind("mousedown.multiselect") - }) - }, - shapeEditable: function(d) { - var c = $("#designer_canvas"); - if (d.attribute.editable == false) { - return - } - c.unbind("dblclick.edit").bind("dblclick.edit", - function() { - Designer.op.editShapeText(d); - c.unbind("dblclick.edit") - }) - }, - editShapeText: function(o) { - if (o.name == "linker") { - this.editLinkerText(o); - return - } - var j = $("#shape_text_edit"); - if (j.length == 0) { - j = $("").appendTo("#designer_canvas") - } - var k = $("#shape_text_ruler"); - if (k.length == 0) { - k = $("").appendTo("#designer_canvas") - } - $(".text_canvas[forshape=" + o.id + "]").hide(); - var l = o.fontStyle; - var p = o.getTextBlock(); - if (l.orientation == "horizontal") { - var m = { - x: p.x + p.w / 2, - y: p.y + p.h / 2 - }; - p = { - x: m.x - p.h / 2, - y: m.y - p.w / 2, - w: p.h, - h: p.w - } - } - var n = { - width: p.w + "px", - "z-index": Model.orderList.length + 2, - "line-height": Math.round(l.size * 1.25) + "px", - "font-size": l.size + "px", - "font-family": l.fontFamily, - "font-weight": l.bold ? "bold": "normal", - "font-style": l.italic ? "italic": "normal", - "text-align": l.textAlign, - color: "rgb(" + l.color + ")", - "text-decoration": l.underline ? "underline": "none" - }; - j.css(n); - k.css(n); - j.show(); - p.x += o.props.x; - p.y += o.props.y; - j.val(o.text); - $("#shape_text_edit").unbind().bind("keyup", - function() { - var a = $(this).val(); - k.val(a); - k.scrollTop(99999); - var h = k.scrollTop(); - j.css({ - height: h - }); - var g = { - x: p.x + p.w / 2, - y: p.y + p.h / 2 - }; - var f = 0; - var d = 0; - var w = p.h; - if (o.fontStyle.vAlign == "middle") { - if (h > w) { - w = h; - f = (g.y - w / 2); - d = 0 - } else { - f = (g.y - p.h / 2); - d = (p.h - h) / 2; - w = p.h - d - } - } else { - if (o.fontStyle.vAlign == "bottom") { - if (h > w) { - w = h; - f = (g.y + p.h / 2 - w); - d = 0 - } else { - f = (g.y - p.h / 2); - d = p.h - h; - w = p.h - d - } - } else { - f = (g.y - p.h / 2); - d = 0; - if (h > w) { - w = h - } else { - w = p.h - } - } - } - var x = d + w; - var b = { - x: p.x + p.w / 2, - y: f + x / 2 - }; - var c = o.props.angle; - if (c != 0) { - var v = { - x: o.props.x + o.props.w / 2, - y: o.props.y + o.props.h / 2 - }; - b = Utils.getRotated(v, b, c) - } - if (l.orientation == "horizontal") { - c = (Math.PI * 1.5 + c) % (Math.PI * 2) - } - var u = Math.round(c / (Math.PI * 2) * 360); - var e = "rotate(" + u + "deg) scale(" + Designer.config.scale + ")"; - j.css({ - width: p.w, - height: w, - "padding-top": d, - left: b.x.toScale() - p.w / 2 - 2, - top: b.y.toScale() - x / 2 - 2, - "-webkit-transform": e, - "-ms-transform": e, - "-o-transform": e, - "-moz-transform": e, - transform: e - }) - }).bind("keydown", - function(a) { - var d = $(this); - if (a.keyCode == 13 && a.ctrlKey) { - i(); - return false - } else { - if (a.keyCode == 27) { - d.unbind().remove(); - $(".text_canvas[forshape=" + o.id + "]").show() - } else { - if (a.keyCode == 66 && a.ctrlKey) { - var c = !o.fontStyle.bold; - o.fontStyle.bold = c; - Model.update(o); - var b = c ? "bold": "normal"; - $(this).css("font-weight", b); - k.css("font-weight", b); - UI.update() - } else { - if (a.keyCode == 73 && a.ctrlKey) { - var c = !o.fontStyle.italic; - o.fontStyle.italic = c; - Model.update(o); - var b = c ? "italic": "normal"; - $(this).css("font-style", b); - k.css("font-style", b); - UI.update() - } else { - if (a.keyCode == 85 && a.ctrlKey) { - var c = !o.fontStyle.underline; - o.fontStyle.underline = c; - Model.update(o); - var b = c ? "underline": "none"; - $(this).css("text-decoration", b); - k.css("text-decoration", b); - a.preventDefault(); - UI.update() - } - } - } - } - } - }).bind("blur", - function(a) { - i() - }).bind("mousemove", - function(a) { - a.stopPropagation() - }).bind("mousedown", - function(a) { - a.stopPropagation() - }).bind("mouseenter", - function(a) { - Designer.op.destroy() - }); - $("#shape_text_edit").trigger("keyup"); - j.select(); - function i() { - var a = $("#shape_text_edit").val(); - if ($("#shape_text_edit").length && $("#shape_text_edit").is(":visible")) { - if (a != o.text) { - o.text = a; - Model.update(o) - } - Designer.painter.renderShape(o); - $("#shape_text_edit").remove() - } - } - }, - shapeLinkable: function(j, g) { - var i = $("#designer_canvas"); - var f = $("#canvas_container"); - f.unbind("mousedown.link").bind("mousedown.link", - function(c) { - Designer.op.changeState("linking_from_shape"); - var e = null; - var d = null; - var a; - if (!j) { - var b = Utils.getRelativePos(c.pageX, c.pageY, i); - a = { - x: b.x.restoreScale(), - y: b.y.restoreScale(), - id: null, - angle: null - } - } else { - a = g; - a.id = j.id - } - f.bind("mousemove.link", - function(m) { - f.css("cursor", "default"); - var n = Utils.getRelativePos(m.pageX, m.pageY, i); - if (d == null) { - d = h(a, n); - Designer.events.push("linkerCreating", d) - } - Designer.op.moveLinker(d, "to", n.x, n.y); - $(document).unbind("mouseup.droplinker").bind("mouseup.droplinker", - function() { - if (Math.abs(n.x - a.x) > 20 || Math.abs(n.y - a.y) > 20) { - Model.add(d); - Designer.events.push("linkerCreated", d); - if (d.to.id == null && d.from.id != null) { - Designer.op.linkDashboard(d) - } - Utils.showLinkerCursor() - } else { - $("#" + d.id).remove() - } - $(document).unbind("mouseup.droplinker") - }) - }); - $(document).bind("mouseup.link", - function() { - Designer.op.hideLinkPoint(); - Designer.op.resetState(); - f.unbind("mousedown.link"); - f.unbind("mousemove.link"); - $(document).unbind("mouseup.link") - }) - }); - function h(a, b) { - var d = Utils.newId(); - var c = Utils.copy(Schema.linkerDefaults); - c.from = a; - c.to = { - id: null, - x: b.x, - y: b.y, - angle: null - }; - c.props = { - zindex: Model.maxZIndex + 1 - }; - c.id = d; - return c - } - }, - linkerEditable: function(c) { - var d = $("#designer_canvas"); - d.unbind("dblclick.edit_linker").bind("dblclick.edit_linker", - function() { - Designer.op.editLinkerText(c); - d.unbind("dblclick.edit_linker") - }) - }, - editLinkerText: function(n) { - Designer.contextMenu.hide(); - var o = Designer.painter.getLinkerMidpoint(n); - var k = $("#" + n.id).find(".text_canvas"); - var i = $("#linker_text_edit"); - if (i.length == 0) { - i = $("").appendTo("#designer_canvas") - } - $("#" + n.id).find(".text_canvas").hide(); - var l = n.fontStyle; - var m = "scale(" + Designer.config.scale + ")"; - var j = Math.round(l.size * 1.25); - i.css({ - "z-index": Model.orderList.length, - "line-height": j + "px", - "font-size": l.size + "px", - "font-family": l.fontFamily, - "font-weight": l.bold ? "bold": "normal", - "font-style": l.italic ? "italic": "normal", - "text-align": l.textAlign, - color: "rgb(" + l.color + ")", - "text-decoration": l.underline ? "underline": "none", - "-webkit-transform": m, - "-ms-transform": m, - "-o-transform": m, - "-moz-transform": m, - transform: m - }); - i.val(n.text).show().select(); - i.unbind().bind("keyup", - function() { - var b = $(this).val(); - var a = b.replace(//g, ">").replace(/\n/g, "
"); - k.html(a + "
"); - var d = k.width(); - if (d < 50) { - d = 50 - } - var c = k.height(); - if (c < j) { - c = j - } - i.css({ - left: o.x.toScale() - d / 2 - 2, - top: o.y.toScale() - c / 2 - 2, - width: d, - height: c - }) - }).bind("mousedown", - function(a) { - a.stopPropagation() - }).bind("keydown", - function(a) { - if (a.keyCode == 13 && a.ctrlKey) { - p(); - return false - } else { - if (a.keyCode == 27) { - i.unbind().remove(); - Designer.painter.renderLinkerText(n) - } else { - if (a.keyCode == 66 && a.ctrlKey) { - var c = !n.fontStyle.bold; - n.fontStyle.bold = c; - Model.update(n); - var b = c ? "bold": "normal"; - $(this).css("font-weight", b); - k.css("font-weight", b); - UI.update() - } else { - if (a.keyCode == 73 && a.ctrlKey) { - var c = !n.fontStyle.italic; - n.fontStyle.italic = c; - Model.update(n); - var b = c ? "italic": "normal"; - $(this).css("font-style", b); - k.css("font-style", b); - UI.update() - } else { - if (a.keyCode == 85 && a.ctrlKey) { - var c = !n.fontStyle.underline; - n.fontStyle.underline = c; - Model.update(n); - var b = c ? "underline": "none"; - $(this).css("text-decoration", b); - k.css("text-decoration", b); - a.preventDefault(); - UI.update() - } - } - } - } - } - }).bind("blur", - function() { - p() - }); - i.trigger("keyup"); - function p() { - var b = $("#linker_text_edit"); - if (b.length && b.is(":visible")) { - var a = b.val(); - if (a != n.text) { - n.text = a; - Model.update(n) - } - Designer.painter.renderLinker(n); - b.remove() - } - } - }, - linkerDraggable: function(g, f) { - var h = $("#designer_canvas"); - var e = $("#canvas_container"); - h.bind("mousedown.draglinker", - function(b) { - Utils.hideLinkerControls(); - Designer.op.changeState("dragging_linker"); - var c = Utils.getSelectedIds(); - var a = false; - if (c.length > 1) { - a = true - } - e.bind("mousemove.draglinker", - function(d) { - e.css("cursor", "default"); - var j = Utils.getRelativePos(d.pageX, d.pageY, h); - Designer.op.moveLinker(g, f, j.x, j.y); - if (a) { - Designer.painter.drawControls(c) - } - $(document).unbind("mouseup.droplinker").bind("mouseup.droplinker", - function() { - $(document).unbind("mouseup.droplinker"); - Model.update(g); - Utils.showLinkerControls() - }) - }); - $(document).bind("mouseup.draglinker", - function() { - Designer.op.hideLinkPoint(); - Designer.op.resetState(); - h.unbind("mousedown.draglinker"); - e.unbind("mousemove.draglinker"); - $(document).unbind("mouseup.draglinker"); - Utils.showLinkerControls() - }) - }) - }, - linkClickable: function(e, f) { - var d = $("#link_spot"); - if (d.length == 0) { - d = $("").appendTo("#designer_canvas") - } - if (e.trim().toLowerCase().indexOf("http") == -1) { - e = "http://" + e - } - d.show().css({ - left: f.x - 50, - top: f.y - 50, - "z-index": Model.orderList.length + 1 - }) - }, - textCreatable: function() { - var c = $("#designer_canvas"); - var d = $("#canvas_container"); - d.unbind("mousedown.create_text").bind("mousedown.create_text", - function(a) { - var g = null; - if (!a.ctrlKey) { - Utils.unselect() - } - var h = Utils.getRelativePos(a.pageX, a.pageY, c); - var b = null; - d.bind("mousemove.create_text", - function(f) { - if (g == null) { - g = $("
").appendTo(c) - } - var e = Utils.getRelativePos(f.pageX, f.pageY, c); - b = { - "z-index": Model.orderList.length, - left: e.x - 1, - top: e.y - 1 - }; - if (e.x > h.x) { - b.left = h.x - 1 - } - if (e.y > h.y) { - b.top = h.y - 1 - } - b.width = Math.abs(e.x - h.x - 2); - b.height = Math.abs(e.y - h.y - 2); - g.css(b) - }); - $(document).unbind("mouseup.create_text").bind("mouseup.create_text", - function(e) { - if (b != null && b.width >= 20 && b.height >= 20) { - var f = Model.create("standardText", b.left.restoreScale(), b.top.restoreScale()); - f.props.w = b.width.restoreScale(); - f.props.h = b.height.restoreScale(); - Model.add(f); - Designer.painter.renderShape(f); - Designer.op.editShapeText(f); - Utils.unselect(); - Utils.selectShape(f.id) - } - g.remove(); - Designer.op.resetState(); - $(document).unbind("mouseup.create_text"); - d.unbind("mousemove.create_text") - }); - d.unbind("mousedown.create_text") - }) - }, - canvasDragTimeout: null, - canvasDraggable: function() { - var b = $("#canvas_container"); - b.css("cursor", "url(../apps/_bpm.platform/js/designer/themes/default/images/diagraming/cursor_hand.png) 8 8, auto"); - if (this.canvasDragTimeout) { - clearTimeout(this.canvasDragTimeout) - } - this.canvasDragTimeout = setTimeout(function() { - b.unbind("mousedown.drag_canvas"); - Designer.op.resetState(); - b.unbind("mousemove.drag_canvas"); - $(document).unbind("mouseup.drag_canvas") - }, - 500); - b.unbind("mousedown.drag_canvas").bind("mousedown.drag_canvas", - function(e) { - var f = $("#designer_layout").scrollTop(); - var a = $("#designer_layout").scrollLeft(); - b.bind("mousemove.drag_canvas", - function(d) { - var h = d.pageX - e.pageX; - var c = d.pageY - e.pageY; - $("#designer_layout").scrollLeft(a - h); - $("#designer_layout").scrollTop(f - c) - }); - $(document).unbind("mouseup.drag_canvas").bind("mouseup.drag_canvas", - function(c) { - b.unbind("mousemove.drag_canvas"); - $(document).unbind("mouseup.drag_canvas") - }) - }); - $(document).unbind("keyup.drag_canvas").bind("keyup.drag_canvas", - function(a) { - b.unbind("mousedown.drag_canvas"); - Designer.op.resetState(); - $(document).unbind("mouseup.drag_canvas"); - a.preventDefault(); - clearTimeout(this.canvasDragTimeout); - b.unbind("mousemove.drag_canvas") - }) - }, - canvasFreeDraggable: function() { - var b = $("#canvas_container"); - b.css("cursor", "url(../apps/_bpm.platform/js/designer/themes/default/images/diagraming/cursor_hand.png) 8 8, auto"); - b.unbind("mousedown.drag_canvas").bind("mousedown.drag_canvas", - function(e) { - var f = $("#designer_layout").scrollTop(); - var a = $("#designer_layout").scrollLeft(); - b.bind("mousemove.drag_canvas", - function(d) { - var h = d.pageX - e.pageX; - var c = d.pageY - e.pageY; - $("#designer_layout").scrollLeft(a - h); - $("#designer_layout").scrollTop(f - c) - }); - $(document).unbind("mouseup.drag_canvas").bind("mouseup.drag_canvas", - function(c) { - b.unbind("mousemove.drag_canvas"); - $(document).unbind("mouseup.drag_canvas") - }) - }) - }, - moveShape: function(A, H) { - var z = []; - for (var x = 0; x < A.length; x++) { - var M = A[x]; - z.push(M.id) - } - var i = Utils.restoreScale(H); - for (var x = 0; x < A.length; x++) { - var M = A[x]; - if (M.name == "linker") { - var D = M; - var y = D.from; - var L = D.to; - var G = false; - var C = false; - if (!Utils.isSelected(D.id)) { - if (y.id != null && z.indexOf(y.id) >= 0) { - D.from.x += i.x; - D.from.y += i.y; - G = true - } - if (L.id != null && z.indexOf(L.id) >= 0) { - D.to.x += i.x; - D.to.y += i.y; - C = true - } - } else { - if (y.id == null || z.indexOf(y.id) >= 0) { - D.from.x += i.x; - D.from.y += i.y; - G = true - } - if (L.id == null || z.indexOf(L.id) >= 0) { - D.to.x += i.x; - D.to.y += i.y; - C = true - } - } - if (G && C) { - for (var w = 0; w < D.points.length; w++) { - var B = D.points[w]; - B.x += i.x; - B.y += i.y - } - var p = $("#" + M.id); - var J = p.position(); - p.css({ - left: J.left += H.x, - top: J.top += H.y - }) - } else { - if (G || C) { - Designer.painter.renderLinker(D, true) - } - } - } else { - N(M); - $(".shape_contour[forshape=" + M.id + "]").css({ - left: M.props.x.toScale(), - top: M.props.y.toScale() - }) - } - } - var K = Utils.getSelectedLinkerIds(); - if (A.length == 1 && K.length == 1) { - return - } - if (K.length > 0) { - var I = Utils.getSelectedIds(); - Designer.painter.drawControls(I) - } else { - var E = $("#shape_controls"); - E.css({ - left: parseFloat(E.css("left")) + H.x, - top: parseFloat(E.css("top")) + H.y - }) - } - var F = $("#shape_controls").position(); - if (F && Utils.getSelected().length > 0) { - Designer.op.showTip("X: " + Math.round(F.left.restoreScale()) + "  Y: " + Math.round(F.top.restoreScale())); - } - function N(a) { - a.props.x += i.x; - a.props.y += i.y; - var b = $("#" + a.id); - b.css({ - left: parseFloat(b.css("left")) + H.x, - top: parseFloat(b.css("top")) + H.y - }) - } - }, - moveLinker: function(D, w, G, H) { - var K = null; - var C = null; - var z = Utils.getShapeByPosition(G, H, true); - Designer.op.hideLinkPoint(); - if (z != null) { - var L = z.shape; - Utils.showAnchors(L); - C = L.id; - if (z.type == "bounding") { - K = z.linkPoint; - Designer.op.showLinkPoint(Utils.toScale(K)) - } else { - if (z.type == "shape") { - var u; - var I; - if (w == "from") { - u = { - x: D.to.x, - y: D.to.y - }; - I = D.to.id - } else { - u = { - x: D.from.x, - y: D.from.y - }; - I = D.from.id - } - if (L.id == I) { - Designer.op.hideLinkPoint(); - K = { - x: G.restoreScale(), - y: H.restoreScale() - }; - K.angle = null; - C = null - } else { - var B = L.getAnchors(); - var E = -1; - var A; - var t = { - x: L.props.x + L.props.w / 2, - y: L.props.y + L.props.h / 2 - }; - for (var v = 0; v < B.length; v++) { - var y = B[v]; - var F = Utils.getRotated(t, { - x: L.props.x + y.x, - y: L.props.y + y.y - }, - L.props.angle); - var x = Utils.measureDistance(F, u); - if (E == -1 || x < E) { - E = x; - A = F - } - } - var J = Utils.getPointAngle(L.id, A.x, A.y, 7); - K = { - x: A.x, - y: A.y, - angle: J - }; - Designer.op.showLinkPoint(Utils.toScale(K)) - } - } - } - } else { - Designer.op.hideLinkPoint(); - Utils.hideAnchors(); - K = { - x: G.restoreScale(), - y: H.restoreScale() - }; - K.angle = null; - C = null - } - if (w == "from") { - D.from.id = C; - D.from.x = K.x; - D.from.y = K.y; - D.from.angle = K.angle; - if (C == null) { - if (K.x >= D.to.x - 6 && K.x <= D.to.x + 6) { - D.from.x = D.to.x - } - if (K.y >= D.to.y - 6 && K.y <= D.to.y + 6) { - D.from.y = D.to.y - } - } - } else { - D.to.x = K.x; - D.to.y = K.y; - D.to.id = C; - D.to.angle = K.angle; - if (C == null) { - if (K.x >= D.from.x - 6 && K.x <= D.from.x + 6) { - D.to.x = D.from.x - } - if (K.y >= D.from.y - 6 && K.y <= D.from.y + 6) { - D.to.y = D.from.y - } - } - } - Designer.painter.renderLinker(D, true) - }, - showLinkPoint: function(e) { - var f = $("").appendTo($("#designer_canvas")); - var d = f[0].getContext("2d"); - d.translate(1, 1); - d.lineWidth = 1; - d.globalAlpha = 0.3; - d.strokeStyle = Designer.config.anchorColor; - d.fillStyle = Designer.config.anchorColor; - d.beginPath(); - d.moveTo(0, 15); - d.bezierCurveTo(0, -5, 30, -5, 30, 15); - d.bezierCurveTo(30, 35, 0, 35, 0, 15); - d.closePath(); - d.fill(); - d.stroke(); - f.css({ - left: e.x - 16, - top: e.y - 16, - "z-index": Model.orderList.length - }).show() - }, - hideLinkPoint: function() { - $(".link_point_canvas").hide() - }, - brokenLinkerChangable: function(k, l) { - var h = $("#canvas_container"); - var g = $("#designer_canvas"); - var i = k.points[l - 1]; - var j = k.points[l]; - if (i.x == j.x) { - h.css("cursor", "e-resize") - } else { - h.css("cursor", "n-resize") - } - g.bind("mousedown.brokenLinker", - function(a) { - Designer.op.changeState("changing_broken_linker"); - var b = Utils.getRelativePos(a.pageX, a.pageY, g); - var c = Utils.getSelectedIds(); - h.bind("mousemove.brokenLinker", - function(e) { - var f = Utils.getRelativePos(e.pageX, e.pageY, g); - var d = { - x: f.x - b.x, - y: f.y - b.y - }; - d = Utils.restoreScale(d); - if (i.x == j.x) { - i.x += d.x; - j.x += d.x - } else { - i.y += d.y; - j.y += d.y - } - Designer.painter.renderLinker(k); - if (c.length > 1) { - Designer.painter.drawControls(c) - } - b = f; - $(document).unbind("mouseup.changed").bind("mouseup.changed", - function() { - Model.update(k); - $(document).unbind("mouseup.changed") - }) - }); - $(document).bind("mouseup.brokenLinker", - function() { - Designer.op.resetState(); - h.unbind("mousemove.brokenLinker"); - g.unbind("mousedown.brokenLinker"); - $(document).unbind("mouseup.brokenLinker") - }) - }) - }, - removeShape: function() {// 在designer.extend.core.js重写 - var d = Utils.getSelected(); - if (d.length > 0) { - Utils.unselect(); - var e = Utils.getAttachedShapes(d); - d = d.concat(e); - var c = []; - for (var b = 0; b < d.length; b++) { - var a = Utils.getChildrenShapes(d[b]); - c = c.concat(a) - } - d = d.concat(c); - if (d.length > 0) { - var shapeIds = []; - for (var index = 0; index < d.length; index++) { - if (d[index].name != "linker") { - shapeIds.push(d[index].id) - } - } - if (shapeIds.length > 0) { - $.ajax({ - url: "./jd?sid=" + $("#sid").val() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_relation_search", - data: { - shapeIds: shapeIds.join(","), - fileId: ruuid - }, - success: function(msg) { - if (typeof(msg) == "string") { - msg = eval("(" + msg + ")") - } - var relationShapes = msg.data.relationShapes; - if (relationShapes.length > 0) { - var options = { - title: "提示", - content: "图形[" + relationShapes + "]被关联,确定删除吗?", - onConfirm: function() { - Model.remove(d) - } - }; - $.confirm(options) - } else { - Model.remove(d) - } - } - }) - } else { - Model.remove(d) - } - } - } - }, - showTip: function(h) { - var f = $("#designer_op_tip"); - if (f.length == 0) { - f = $("
").appendTo("#designer_canvas") - } - f.stop().html(h); - var e = $("#shape_controls"); - var g = e.position(); - f.css({ - top: g.top + e.height() + 5, - left: g.left + e.width() / 2 - f.outerWidth() / 2, - "z-index": Model.orderList.length - }).show() - }, - hideTip: function() { - $("#designer_op_tip").fadeOut(100) - }, - snapLine: function(R, Q, S, ae) { - var U = R.y; - var J = R.y + R.h / 2; - var ad = R.y + R.h; - var af = R.x; - var T = R.x + R.w / 2; - var X = R.x + R.w; - var ag = 2; - var ab = { - v: null, - h: null, - attach: null - }; - var W = null; - if (S) { - W = ae - } else { - W = Model.getShapeById(Q[0]) - } - if (Q.length == 1 && W.groupName == "boundaryEvent") { - for (var K = Model.orderList.length - 1; K >= 0; K--) { - var P = Model.orderList[K].id; - var ai = Model.getShapeById(P); - if (ai.name != "linker" && ai.id != W.id) { - var O = ai.props; - if (ab.attach == null && O.angle == 0 && (ai.groupName == "task" || ai.groupName == "callActivity" || ai.groupName == "subProcess")) { - var p = { - x: O.x - ag, - y: O.y - ag, - w: O.w + ag * 2, - h: O.h + ag * 2 - }; - if (Utils.pointInRect(T, J, p)) { - var aj = O.y; - var ac = O.y + O.h; - var M = O.x; - var L = O.x + O.w; - var V = false; - var aa = false; - if (aj >= J - ag && aj <= J + ag) { - R.y = aj - R.h / 2; - aa = true - } else { - if (ac >= J - ag && ac <= J + ag) { - R.y = ac - R.h / 2; - aa = true - } - } - if (M >= T - ag && M <= T + ag) { - R.x = M - R.w / 2; - V = true - } else { - if (L >= T - ag && L <= T + ag) { - R.x = L - R.w / 2; - V = true - } - } - if (V || aa) { - ab.attach = ai - } - } - } - } - } - } - if (ab.attach == null) { - for (var K = Model.orderList.length - 1; K >= 0; K--) { - var P = Model.orderList[K].id; - var ai = Model.getShapeById(P); - if (ai.name == "linker" || Q.indexOf(P) >= 0 || ai.parent) { - continue - } - var O = ai.props; - if (ab.h == null) { - var aj = O.y; - var ak = O.y + O.h / 2; - var ac = O.y + O.h; - if (ak >= J - ag && ak <= J + ag) { - ab.h = { - type: "middle", - y: ak - }; - R.y = ak - R.h / 2 - } else { - if (aj >= U - ag && aj <= U + ag) { - ab.h = { - type: "top", - y: aj - }; - R.y = aj - } else { - if (ac >= ad - ag && ac <= ad + ag) { - ab.h = { - type: "bottom", - y: ac - }; - R.y = ac - R.h - } else { - if (ac >= U - ag && ac <= U + ag) { - ab.h = { - type: "top", - y: ac - }; - R.y = ac - } else { - if (aj >= ad - ag && aj <= ad + ag) { - ab.h = { - type: "bottom", - y: aj - }; - R.y = aj - R.h - } - } - } - } - } - } - if (ab.v == null) { - var M = O.x; - var N = O.x + O.w / 2; - var L = O.x + O.w; - if (N >= T - ag && N <= T + ag) { - ab.v = { - type: "center", - x: N - }; - R.x = N - R.w / 2 - } else { - if (M >= af - ag && M <= af + ag) { - ab.v = { - type: "left", - x: M - }; - R.x = M - } else { - if (L >= X - ag && L <= X + ag) { - ab.v = { - type: "right", - x: L - }; - R.x = L - R.w - } else { - if (L >= af - ag && L <= af + ag) { - ab.v = { - type: "left", - x: L - }; - R.x = L - } else { - if (M >= X - ag && M <= X + ag) { - ab.v = { - type: "right", - x: M - }; - R.x = M - R.w - } - } - } - } - } - } - if (ab.h != null && ab.v != null) { - break - } - } - } - this.hideSnapLine(); - var ah = $("#designer_canvas"); - if (ab.attach != null) { - var Y = $("#designer_op_snapline_attach"); - if (Y.length == 0) { - Y = $("
").appendTo(ah) - } - var I = ab.attach; - var al = I.lineStyle.lineWidth; - Y.css({ - width: (I.props.w + al).toScale(), - height: (I.props.h + al).toScale(), - left: (I.props.x - al / 2).toScale() - 2, - top: (I.props.y - al / 2).toScale() - 2, - "z-index": $("#" + I.id).css("z-index") - }).show() - } - if (ab.h != null) { - var i = $("#designer_op_snapline_h"); - if (i.length == 0) { - i = $("
").appendTo(ah) - } - i.css({ - width: ah.width() + Designer.config.pageMargin * 2, - left: -Designer.config.pageMargin, - top: Math.round(ab.h.y.toScale()), - "z-index": Model.orderList.length + 1 - }).show() - } - if (ab.v != null) { - var Z = $("#designer_op_snapline_v"); - if (Z.length == 0) { - Z = $("
").appendTo(ah) - } - Z.css({ - height: ah.height() + Designer.config.pageMargin * 2, - top: -Designer.config.pageMargin, - left: Math.round(ab.v.x.toScale()), - "z-index": Model.orderList.length + 1 - }).show() - } - return ab - }, - snapResizeLine: function(K, I, J) { - var L = K.y; - var i = K.y + K.h / 2; - var P = K.y + K.h; - var Q = K.x; - var C = K.x + K.w / 2; - var D = K.x + K.w; - var R = 2; - var N = { - v: null, - h: null - }; - for (var F = Model.orderList.length - 1; F >= 0; F--) { - var B = Model.orderList[F].id; - var U = Model.getShapeById(B); - if (U.name == "linker" || I.indexOf(B) >= 0 || U.parent) { - continue - } - var H = U.props; - if (N.h == null && (J.indexOf("t") >= 0 || J.indexOf("b") >= 0)) { - var T = H.y; - var V = H.y + H.h / 2; - var O = H.y + H.h; - if (V >= i - R && V <= i + R) { - N.h = { - type: "middle", - y: V - }; - if (J.indexOf("t") >= 0) { - K.h = (P - V) * 2; - K.y = P - K.h - } else { - K.h = (V - K.y) * 2 - } - } else { - if (J.indexOf("t") >= 0 && T >= L - R && T <= L + R) { - N.h = { - type: "top", - y: T - }; - K.y = T; - K.h = P - T - } else { - if (J.indexOf("b") >= 0 && O >= P - R && O <= P + R) { - N.h = { - type: "bottom", - y: O - }; - K.h = O - L - } else { - if (J.indexOf("t") >= 0 && O >= L - R && O <= L + R) { - N.h = { - type: "top", - y: O - }; - K.y = O; - K.h = P - O - } else { - if (J.indexOf("b") >= 0 && T >= P - R && T <= P + R) { - N.h = { - type: "bottom", - y: T - }; - K.h = T - K.y - } - } - } - } - } - } - if (N.v == null && (J.indexOf("l") >= 0 || J.indexOf("r") >= 0)) { - var p = H.x; - var A = H.x + H.w / 2; - var G = H.x + H.w; - if (A >= C - R && A <= C + R) { - N.v = { - type: "center", - x: A - }; - if (J.indexOf("l") >= 0) { - K.w = (D - A) * 2; - K.x = D - K.w - } else { - K.w = (A - K.x) * 2 - } - } else { - if (J.indexOf("l") >= 0 && p >= Q - R && p <= Q + R) { - N.v = { - type: "left", - x: p - }; - K.x = p; - K.w = D - p - } else { - if (J.indexOf("r") >= 0 && G >= D - R && G <= D + R) { - N.v = { - type: "right", - x: G - }; - K.w = G - K.x - } else { - if (J.indexOf("l") >= 0 && G >= Q - R && G <= Q + R) { - N.v = { - type: "left", - x: G - }; - K.x = G; - K.w = D - G - } else { - if (J.indexOf("r") >= 0 && p >= D - R && p <= D + R) { - N.v = { - type: "right", - x: p - }; - K.w = p - K.x - } - } - } - } - } - } - if (N.h != null && N.v != null) { - break - } - } - this.hideSnapLine(); - var S = $("#designer_canvas"); - if (N.h != null) { - var E = $("#designer_op_snapline_h"); - if (E.length == 0) { - E = $("
").appendTo(S) - } - E.css({ - width: S.width() + Designer.config.pageMargin * 2, - left: -Designer.config.pageMargin, - top: Math.round(N.h.y.toScale()), - "z-index": Model.orderList.length + 1 - }).show() - } - if (N.v != null) { - var M = $("#designer_op_snapline_v"); - if (M.length == 0) { - M = $("
").appendTo(S) - } - M.css({ - height: S.height() + Designer.config.pageMargin * 2, - top: -Designer.config.pageMargin, - left: Math.round(N.v.x.toScale()), - "z-index": Model.orderList.length + 1 - }).show() - } - return N - }, - hideSnapLine: function() { - $("#designer_op_snapline_h").hide(); - $("#designer_op_snapline_v").hide(); - $("#designer_op_snapline_attach").hide() - }, - linkDashboard: function(q) { - var m = Model.getShapeById(q.from.id); - var t = m.category; - if ($("#panel_" + t).length != 0) { - var p = $("#shape_dashboard_" + t); - if (p.length == 0) { - p = $("").appendTo("#designer_canvas"); - function r(b, d) { - var e = "
"; - var c = $(e).appendTo(p); - if (d) { - c.append("") - } - var a = c.children()[0]; - Designer.painter.drawPanelItem(a, b.name) - } - for (var l in Schema.shapes) { - var o = Schema.shapes[l]; - if ((o.category == "process_bpmn2" || o.category == "process.bpmn2" || o.category == "bpmn") && checkRunningTimeShape(o)) { - continue; - } - if (o.category == t) { - var s = o.attribute; - if (s.visible && s.linkable) { - if (!o.groupName) { - r(o) - } else { - var k = SchemaGroup.getGroup(o.groupName); - if (k[0] == o.name) { - r(o, o.groupName) - } - } - } - } - } - p.bind("mousemove", - function(a) { - a.stopPropagation() - }).bind("mousedown", - function(a) { - a.stopPropagation() - }) - } - p.css({ - left: q.to.x.toScale(), - top: q.to.y.toScale(), - "z-index": Model.orderList.length - }).show(); - p.find(".link_shape_icon").unbind().bind("mousedown", - function(f) { - f.stopPropagation(); - var a = $(this).attr("group"); - var d = $(this).parent().position(); - var e = p.position(); - var b = d.left + e.left + $(this).parent().outerWidth() - 10; - var c = d.top + e.top + $(this).parent().outerHeight(); - Designer.op.groupDashboard(a, b, c, - function(g) { - n(g); - p.hide(); - $(document).unbind("mousedown.dashboard") - }) - }).bind("click", - function(a) { - a.stopPropagation() - }); - p.children(".dashboard_box").unbind().bind("click", - function() { - p.hide(); - $(document).unbind("mousedown.dashboard"); - var a = $(this); - var b = a.attr("shapeName"); - n(b) - }); - initRunningDashboard(p); - $(document).bind("mousedown.dashboard", - function() { - p.hide(); - $(document).unbind("mousedown.dashboard") - }); - function n(e) { - var y = Schema.shapes[e]; - var d = Utils.getEndpointAngle(q, "to"); - var b = Utils.getAngleDir(d); - var f = y.getAnchors(); - var A; - if (b == 1) { - var c = null; - for (var j = 0; j < f.length; j++) { - var z = f[j]; - if (c == null || z.y < c) { - c = z.y; - A = z - } - } - } else { - if (b == 2) { - var g = null; - for (var j = 0; j < f.length; j++) { - var z = f[j]; - if (g == null || z.x > g) { - g = z.x; - A = z - } - } - } else { - if (b == 3) { - var h = null; - for (var j = 0; j < f.length; j++) { - var z = f[j]; - if (h == null || z.y > h) { - h = z.y; - A = z - } - } - } else { - if (b == 4) { - var B = null; - for (var j = 0; j < f.length; j++) { - var z = f[j]; - if (B == null || z.x < B) { - B = z.x; - A = z - } - } - } - } - } - } - var i = Model.create(e, q.to.x - A.x, q.to.y - A.y); - Designer.painter.renderShape(i); - MessageSource.beginBatch(); - if (i.onCreated) { - i.onCreated() - } - Designer.events.push("created", i); - Model.add(i); - var a = Utils.getPointAngle(i.id, q.to.x, q.to.y, 7); - q.to.id = i.id; - q.to.angle = a; - Designer.painter.renderLinker(q, true); - Model.update(q); - MessageSource.commit(); - Utils.unselect(); - Utils.selectShape(i.id); - Designer.op.editShapeText(i) - } - } - }, - groupDashboard: function(m, s, n, t) { - $(".group_dashboard").hide(); - var o = $("#shape_group_dashboard_" + m); - if (o.length == 0) { - o = $("").appendTo("#designer_canvas"); - var i = SchemaGroup.getGroup(m); - for (var r = 0; r < i.length; r++) { - var v = i[r]; - var p = Schema.shapes[v]; - if ((p.category == "process_bpmn2" || p.category == "process.bpmn2" || p.category == "bpmn") && checkRunningTimeShape(p)) { - continue; - } - if (p.attribute.visible) { - var q = $("
").appendTo(o); - var u = q.children("canvas")[0]; - Designer.painter.drawPanelItem(u, p.name) - } - } - o.bind("mousedown", - function(a) { - a.stopPropagation() - }) - } - o.css({ - left: s, - top: n, - "z-index": Model.orderList.length + 1 - }).show(); - $(".dashboard_box").unbind().bind("click", - function() { - var a = $(this).attr("shapeName"); - t(a); - o.hide(); - $(document).unbind("mousedown.group_dashboard") - }); - $(document).bind("mousedown.group_dashboard", - function() { - o.hide(); - $(document).unbind("mousedown.group_dashboard") - }); - return o - }, - showPanelGroup: function(o, z, t) { - z.stopPropagation(); - var s = $("#group_dashboard_" + o); - $(".group_dashboard").hide(); - if (s.length == 0) { - s = $("").appendTo("#designer"); - var i = SchemaGroup.getGroup(o); - for (var v = 0; v < i.length; v++) { - var y = i[v]; - var r = Schema.shapes[y]; - if ((r.category == "process_bpmn2" || r.category == "process.bpmn2" || r.category == "bpmn") && checkRunningTimeShape(r)) { - continue; - } - if (r.attribute.visible) { - var title = r.title; - var category = r.category; - if (r.category == "bpmn") { - category = 'process_bpmn2'; - } - category = category.replace(/_/g,"."); - if (category == 'lane') { - category = methodId; - } - if (methodObjectDesc[category + '-' + r.name]) { - title += (':' + methodObjectDesc[category + '-' + r.name]); - } - - var u = $("
").appendTo(s); - var x = u.children("canvas")[0]; - Designer.painter.drawPanelItem(x, r.name) - } - } - s.css("position", "fixed") - } - var p = $(t).parent(); - var w = p.offset(); - s.show(); - var q = w.top + p.height(); - if (q + s.outerHeight() > $(window).height()) { - q = $(window).height() - s.outerHeight() - } - s.css({ - left: w.left - 7, - top: q - }); - $(document).bind("mousedown.group_board", - function() { - s.hide(); - $(document).unbind("mousedown.group_board") - }) - }, - changeShapeProps: function(j, o) { - function p(e) { - if (typeof o.x != "undefined") { - e.x += (o.x - j.props.x) - } - if (typeof o.y != "undefined") { - e.y += (o.y - j.props.y) - } - if (typeof o.w != "undefined" || typeof o.h != "undefined" || typeof o.angle != "undefined") { - var f = $.extend({}, - j.props, o); - var g = { - x: j.props.x + j.props.w / 2, - y: j.props.y + j.props.h / 2 - }; - var b = Utils.getRotated(g, e, -j.props.angle); - var c = j.props.w; - var h = j.props.h; - if (typeof o.w != "undefined") { - e.x = j.props.x + (b.x - j.props.x) / j.props.w * o.w; - c = o.w - } else { - e.x = b.x - } - if (typeof o.h != "undefined") { - e.y = j.props.y + (b.y - j.props.y) / j.props.h * o.h; - h = o.h - } else { - e.y = b.y - } - var d = { - x: j.props.x + c / 2, - y: j.props.y + h / 2 - }; - var a = Utils.getRotated(d, e, f.angle); - e.x = a.x; - e.y = a.y - } - if (typeof o.angle != "undefined") { - e.angle += o.angle - j.props.angle - } - } - var m = []; - var l = Model.getShapeLinkers(j.id); - if (l && l.length > 0) { - for (var i = 0; i < l.length; i++) { - var k = l[i]; - var n = Model.getShapeById(k); - if (j.id == n.from.id) { - p(n.from) - } - if (j.id == n.to.id) { - p(n.to) - } - } - m = l - } - $.extend(j.props, o); - Designer.painter.renderShape(j); - Utils.showLinkerCursor(); - return m - } - }, - events: { - push: function(f, e) { - var d = this.listeners[f]; - if (d) { - return d(e) - } - return null - }, - listeners: {}, - addEventListener: function(c, d) { - this.listeners[c] = d - } - }, - clipboard: { - elements: [], - presetedIds: {}, - presetIds: function() { - this.presetedIds = {}; - for (var c = 0; c < this.elements.length; c++) { - var d = this.elements[c]; - this.presetedIds[d.id] = Utils.newId(); - if (d.group && !this.presetedIds[d.group]) { - this.presetedIds[d.group] = Utils.newId() - } - } - }, - plus: true, - copy: function(g) { - this.elements = []; - var j; - var k; - if (g) { - j = g - } else { - j = Utils.getSelected(); - k = Utils.getFamilyShapes(j); - j = j.concat(k) - } - j.sort(function i(a, b) { - return a.props.zindex - b.props.zindex - }); - for (var f = 0; f < j.length; f++) { - var h = Utils.copy(j[f]); - if (h.name == "linker") { - if (h.from.id != null) { - if (!Utils.isSelected(h.from.id) && g == undefined) { - h.from.id = null; - h.from.angle = null - } - } - if (h.to.id != null) { - if (!Utils.isSelected(h.to.id) && g == undefined) { - h.to.id = null; - h.to.angle = null - } - } - } - this.elements.push(h) - } - this.elements.sort(function i(a, b) { - return a.props.zindex - b.props.zindex - }); - this.presetIds(); - this.plus = true; - Designer.events.push("clipboardChanged", this.elements.length) - }, - cut: function() { - this.copy(); - // Designer.op.removeShape();// 重复删除,造成异常 - this.plus = true; - }, - paste: function(F, G) { - if (this.elements.length == 0) { - return - } - var w = 20; - var x = 20; - if (typeof F != "undefined") { - var I = Utils.getShapesBounding(this.elements); - w = F - I.x - I.w / 2; - x = G - I.y - I.h / 2 - } - var H = []; - var K = []; - var j = []; - for (var y = 0; y < this.elements.length; y++) { - var L = this.elements[y]; - if (L.name != "linker") { - var v; - var L = this.elements[y]; - L.props.zindex = Model.maxZIndex + (y + 1); - var D = this.presetedIds[L.id]; - if (this.plus || typeof F != "undefined") { - L.props.x += w; - L.props.y += x - } - v = Utils.copy(L); - for (var A = 0; A < v.dataAttributes.length; A++) { - var B = v.dataAttributes[A]; - B.id = Utils.newId() - } - v.id = D; - if (v.children) { - for (var E = 0; E < v.children.length; E++) { - var z = v.children[E]; - v.children[E] = this.presetedIds[z] - } - } - if (v.parent) { - v.parent = this.presetedIds[v.parent] - } - H.push(v); - K.push(D); - if (L.group) { - var J = this.presetedIds[L.group]; - v.group = J - } - var i = {}; - i.copyShapeId = L.id; - i.pasteShapeId = v.id; - i.pasteFileId = ruuid; - j.push(i) - } - } - for (var y = 0; y < this.elements.length; y++) { - var L = this.elements[y]; - if (L.name == "linker") { - var v; - L.props.zindex = Model.maxZIndex + (y + 1); - var D = this.presetedIds[L.id]; - if (this.plus || typeof F != "undefined") { - L.from.x += w; - L.from.y += x; - L.to.x += w; - L.to.y += x; - for (var p = 0; p < L.points.length; p++) { - var C = L.points[p]; - C.x += w; - C.y += x - } - } - v = Utils.copy(L); - if (!v.dataAttributes) { - v.dataAttributes = [] - } - for (var A = 0; A < v.dataAttributes.length; A++) { - var B = v.dataAttributes[A]; - B.id = Utils.newId() - } - if (L.from.id != null) { - v.from.id = this.presetedIds[L.from.id] - } - if (L.to.id != null) { - v.to.id = this.presetedIds[L.to.id] - } - v.id = D; - H.push(v); - K.push(D); - if (L.group) { - var J = this.presetedIds[L.group]; - v.group = J - } - } - } - Model.addMulti(H); - for (var y = 0; y < H.length; y++) { - var L = H[y]; - Designer.painter.renderShape(L) - } - Model.build(); - this.presetIds(); - Utils.unselect(); - Utils.selectShape(K); - this.plus = true; - return j - }, - duplicate: function() { - this.copy(); - this.paste() - }, - brush: function() { - var h = Utils.getSelected(); - if (h.length == 0) { - return - } - var g = { - fontStyle: {}, - lineStyle: {}, - fillStyle: null, - shapeStyle: null - }; - for (var i = 0; i < h.length; i++) { - var f = h[i]; - if (f.name == "linker") { - $.extend(g.lineStyle, f.lineStyle); - $.extend(g.fontStyle, f.fontStyle) - } else { - if (g.fillStyle == null) { - g.fillStyle = {} - } - if (g.shapeStyle == null) { - g.shapeStyle = {} - } - $.extend(g.lineStyle, f.lineStyle); - $.extend(g.fontStyle, f.fontStyle); - $.extend(g.shapeStyle, f.shapeStyle); - $.extend(g.fillStyle, f.fillStyle) - } - } - $("#bar_brush").button("select"); - var j = $("#designer_op_help"); - if (j.length == 0) { - j = $("
").appendTo("#designer_viewport") - } - j.html("选择目标图形并使用格式刷样式
Esc取消").show(); - $(document).unbind("keydown.cancelbrush").bind("keydown.cancelbrush", - function(a) { - if (a.keyCode == 27) { - $("#bar_brush").button("unselect"); - j.hide(); - $(document).unbind("keydown.cancelbrush"); - Utils.selectCallback = null; - $("#bar_brush").button("disable") - } - }); - Utils.selectCallback = function() { - var b = Utils.getSelected(); - for (var a = 0; a < b.length; a++) { - var c = b[a]; - var d = c.fontStyle.orientation; - $.extend(c.lineStyle, g.lineStyle); - $.extend(c.fontStyle, g.fontStyle); - if (c.name != "linker") { - c.lineStyle = g.lineStyle; - delete c.lineStyle.beginArrowStyle; - delete c.lineStyle.endArrowStyle; - c.fontStyle.orientation = d; - if (g.fillStyle != null) { - c.fillStyle = g.fillStyle - } - if (g.shapeStyle != null) { - c.shapeStyle = g.shapeStyle - } - } else { - delete c.fontStyle.orientation; - delete c.fontStyle.vAlign - } - Designer.painter.renderShape(c) - } - Model.updateMulti(b) - } - } - }, - addFunction: function(c, d) { - if (Designer[c]) { - throw "Duplicate function name!" - } else { - this[c] = d - } - }, - painter: { - actions: { - move: function(b) { - this.moveTo(b.x, b.y); - this.prePoint = b; - if (this.beginPoint == null) { - this.beginPoint = b - } - }, - line: function(d) { - if (typeof this.webkitLineDash != "undefined" && typeof this.lineDashOffset == "undefined" && this.lineWidth != 0) { - var f = this.webkitLineDash; - var c = this.prePoint; - var h = Utils.measureDistance(c, d); - var k = 0; - var b = 1 / h; - var j = c; - var e = 0; - var g = true; - while (k < 1) { - k += b; - if (k > 1) { - k = 1 - } - var i = { - x: (1 - k) * c.x + k * d.x, - y: (1 - k) * c.y + k * d.y - }; - var a = Utils.measureDistance(j, i); - if (a >= f[e] || k >= 1) { - if (g) { - this.lineTo(i.x, i.y) - } else { - this.moveTo(i.x, i.y) - } - g = !g; - j = i; - e++; - if (e >= f.length) { - e = 0 - } - } - } - this.moveTo(d.x, d.y) - } else { - this.lineTo(d.x, d.y) - } - this.prePoint = d; - if (this.beginPoint == null) { - this.beginPoint = d - } - }, - curve: function(e) { - if (typeof this.webkitLineDash != "undefined" && typeof this.lineDashOffset == "undefined" && this.lineWidth != 0) { - var g = this.webkitLineDash; - var d = this.prePoint; - var i = Utils.measureDistance(d, e); - var n = 0; - var b = 1 / i; - var l = d; - var f = 0; - var h = true; - var c = 0; - while (n < 1) { - n += b; - if (n > 1) { - n = 1 - } - var k = { - x: d.x * Math.pow((1 - n), 3) + e.x1 * n * Math.pow((1 - n), 2) * 3 + e.x2 * Math.pow(n, 2) * (1 - n) * 3 + e.x * Math.pow(n, 3), - y: d.y * Math.pow((1 - n), 3) + e.y1 * n * Math.pow((1 - n), 2) * 3 + e.y2 * Math.pow(n, 2) * (1 - n) * 3 + e.y * Math.pow(n, 3) - }; - var a = Utils.measureDistance(l, k); - if (a >= g[f] || n >= 1) { - if (h) { - var m = c + (n - c) / 2; - var j = { - x: d.x * Math.pow((1 - m), 3) + e.x1 * m * Math.pow((1 - m), 2) * 3 + e.x2 * Math.pow(m, 2) * (1 - m) * 3 + e.x * Math.pow(m, 3), - y: d.y * Math.pow((1 - m), 3) + e.y1 * m * Math.pow((1 - m), 2) * 3 + e.y2 * Math.pow(m, 2) * (1 - m) * 3 + e.y * Math.pow(m, 3) - }; - this.lineTo(j.x, j.y); - this.lineTo(k.x, k.y) - } else { - this.moveTo(k.x, k.y) - } - h = !h; - l = k; - c = n; - f++; - if (f >= g.length) { - f = 0 - } - } - } - this.moveTo(e.x, e.y) - } else { - this.bezierCurveTo(e.x1, e.y1, e.x2, e.y2, e.x, e.y) - } - this.prePoint = e; - if (this.beginPoint == null) { - this.beginPoint = e - } - }, - quadraticCurve: function(e) { - if (typeof this.webkitLineDash != "undefined" && typeof this.lineDashOffset == "undefined" && this.lineWidth != 0) { - var g = this.webkitLineDash; - var d = this.prePoint; - var i = Utils.measureDistance(d, e); - var n = 0; - var b = 1 / i; - var l = d; - var f = 0; - var h = true; - var c = 0; - while (n < 1) { - n += b; - if (n > 1) { - n = 1 - } - var k = { - x: d.x * Math.pow((1 - n), 2) + e.x1 * n * (1 - n) * 2 + e.x * Math.pow(n, 2), - y: d.y * Math.pow((1 - n), 2) + e.y1 * n * (1 - n) * 2 + e.y * Math.pow(n, 2) - }; - var a = Utils.measureDistance(l, k); - if (a >= g[f] || n >= 1) { - if (h) { - var m = c + (n - c) / 2; - var j = { - x: d.x * Math.pow((1 - m), 2) + e.x1 * m * (1 - m) * 2 + e.x * Math.pow(m, 2), - y: d.y * Math.pow((1 - m), 2) + e.y1 * m * (1 - m) * 2 + e.y * Math.pow(m, 2) - }; - this.lineTo(j.x, j.y); - this.lineTo(k.x, k.y) - } else { - this.moveTo(k.x, k.y) - } - h = !h; - l = k; - c = n; - f++; - if (f >= g.length) { - f = 0 - } - } - } - this.moveTo(e.x, e.y) - } else { - this.quadraticCurveTo(e.x1, e.y1, e.x, e.y) - } - this.prePoint = e; - if (this.beginPoint == null) { - this.beginPoint = e - } - }, - close: function() { - if (typeof this.webkitLineDash != "undefined" && typeof this.lineDashOffset == "undefined" && this.lineWidth != 0) { - var f = this.webkitLineDash; - var c = this.prePoint; - var d = this.beginPoint; - var h = Utils.measureDistance(c, d); - var k = 0; - var b = 1 / h; - var j = c; - var e = 0; - var g = true; - while (k < 1) { - k += b; - if (k > 1) { - k = 1 - } - var i = { - x: (1 - k) * c.x + k * d.x, - y: (1 - k) * c.y + k * d.y - }; - var a = Utils.measureDistance(j, i); - if (a >= f[e] || k >= 1) { - if (g) { - this.lineTo(i.x, i.y) - } else { - this.moveTo(i.x, i.y) - } - g = !g; - j = i; - e++; - if (e >= f.length) { - e = 0 - } - } - } - } - this.closePath() - } - }, - setLineDash: function(d, c) { - if (!d.setLineDash) { - d.setLineDash = function() {} - } - d.setLineDash(c); - d.mozDash = c; - d.webkitLineDash = c - }, - renderShapePath: function(f, e, h) { - var g; - if (h && e.drawIcon) { - g = e.drawIcon(e.props.w, e.props.h) - } else { - g = e.getPath() - } - this.renderPath(f, e, g, h) - }, - renderPath: function(m, o, i, t) { - for (var q = 0; q < i.length; q++) { - var s = i[q]; - m.save(); - m.beginPath(); - var p = $.extend({}, - o.lineStyle, s.lineStyle); - var n = $.extend({}, - o.fillStyle, s.fillStyle); - for (var r = 0; r < s.actions.length; r++) { - var j = s.actions[r]; - this.actions[j.action].call(m, j) - } - this.fillShape(o, m, n); - if (p.lineWidth) { - m.lineWidth = p.lineWidth; - m.strokeStyle = "rgb(" + p.lineColor + ")"; - if (p.lineStyle == "dashed") { - if (t) { - this.setLineDash(m, [p.lineWidth * 4, p.lineWidth * 2]) - } else { - this.setLineDash(m, [p.lineWidth * 6, p.lineWidth * 3]) - } - } else { - if (p.lineStyle == "dot") { - this.setLineDash(m, [p.lineWidth, p.lineWidth * 2]) - } else { - if (p.lineStyle == "dashdot") { - this.setLineDash(m, [p.lineWidth * 6, p.lineWidth * 2, p.lineWidth, p.lineWidth * 2]) - } - } - } - m.stroke() - } - m.restore() - } - }, - drawPanelItem: function(n, m) { - var i = n.getContext("2d"); - var h = Utils.copy(Schema.shapes[m]); - var l = { - x: 0, - y: 0, - w: h.props.w, - h: h.props.h, - angle: h.props.angle - }; - i.clearRect(0, 0, Designer.config.panelItemWidth, Designer.config.panelItemHeight); - if (l.w >= Designer.config.panelItemWidth || l.h >= Designer.config.panelItemWidth) { - if (h.props.w >= h.props.h) { - l.w = Designer.config.panelItemWidth - h.lineStyle.lineWidth * 2; - l.h = parseInt(h.props.h / h.props.w * l.w) - } else { - l.h = Designer.config.panelItemHeight - h.lineStyle.lineWidth * 2; - l.w = parseInt(h.props.w / h.props.h * l.h) - } - } - h.props = l; - i.save(); - i.lineJoin = "round"; - i.globalAlpha = h.shapeStyle.alpha; - var j = (Designer.config.panelItemWidth - l.w) / 2; - var k = (Designer.config.panelItemHeight - l.h) / 2; - i.translate(j, k); - i.translate(l.w / 2, l.h / 2); - i.rotate(l.angle); - i.translate( - (l.w / 2), -(l.h / 2)); - this.renderShapePath(i, h, true, - function() { - Designer.painter.drawPanelItem(n, m) - }); - this.renderMarkers(i, h, true); - i.restore() - }, - handleShapeConfigData: function(dataArray, q, attributesJsonArray) { - //先去除重复的配置--在拼装数据前,先删除数据 - var temp1; - for (var i = q.dataAttributes.length - 1; i >= 0 ; i--) { - temp1 = q.dataAttributes[i]; - var hor = temp1.horizontal; - var ver = temp1.vertical; - if (temp1.hasOwnProperty("attributesJsonArray")) { - var temp2 = temp1.dataShowConfig; - if (temp2 != undefined) { - temp2.value = []; - } - break - } - } - var key = q.name; - for (var i = 0; i < dataArray.length; i++) { - var temp = dataArray[i]; - var showType = temp.showType; - var horizontal = temp.horizontal; - horizontal = horizontal.toLowerCase(); - var verity = temp.verity; - verity = verity.toLowerCase(); - if (verity == "center") {verity = "middle";} - if (showType == "text" || showType == "attribute") { - var cfgContent = temp.cfgContent; - var params = { - "w":30, - "h":30, - "textw": 20, - "texth": 17, - "imgT": 0, - "category":"custom", - "icon":"", - "name":key, - "showName":false, - "showType":"text", //text icon - "type":"string", - "value":cfgContent, - "horizontal":horizontal, - "vertical":verity, - "radius":5, - "title":"" - }; - if (showType == "attribute") { - var attrId = temp.key; - var attrType = "string"; - if (attributesJsonArray.length > 0) { - for (var j = 0; j < attributesJsonArray.length; j++) { - var attr = attributesJsonArray[j]; - if (attr.key == attrId) { - attrType = attr.type; - cfgContent = attr.value; - break; - } - } - } - var attrTypeArray = ['string', 'select', 'select_m', 'textarea']; - if (temp.isShowAttrName && attrTypeArray.indexOf(attrType) >= 0 && (cfgContent + '').trim().length > 0) { - cfgContent = "(" + temp.attrName + ")" +cfgContent; - } - if (attrType == "relation" && cfgContent.length == 0) { - cfgContent = ""; - } else if (attrType == "relation" && cfgContent.length > 0) { - var shapeIdAttrId = q.id + "_" + attrId; - var relationData = relationShapeModelObject; - var relationValue = ""; - for (var j = 0; j < cfgContent.length; j++) { - if (j == cfgContent.length - 1) { - if (relationData.hasOwnProperty(shapeIdAttrId)) { - var tempRelationValue = relationData[shapeIdAttrId]; - relationValue = relationValue + tempRelationValue; - } - } else if (relationData.hasOwnProperty(shapeIdAttrId)) { - var tempRelationValue = relationData[shapeIdAttrId] + "|"; - relationValue = relationValue + tempRelationValue; - } - } - cfgContent = relationValue; - if (temp.isShowAttrName) { - cfgContent = "(" + temp.attrName + ")" + cfgContent; - } - } - params.showType = "attr"; - params.value = cfgContent; - } - if(!q.dataAttributes){ - q.dataAttributes = []; - } - params.id = Utils.newId(); - params.category = "custom"; - if (!temp1.dataShowConfig){ - temp1.dataShowConfig = {}; - if (!temp1.dataShowConfig.value) { - temp1.dataShowConfig.value = []; - } - } - temp1.dataShowConfig.value.push(params); - //Model.updateMulti([q]); - } else { - var iconContent = temp.iconContent; - var params = { - "w":16, - "h":16, - "textw": 20, - "texth": 17, - "imgT": 0, - "category":"custom", - "icon":iconContent, - "name":key, - "showName":false, - "showType":"icon", //text icon - "type":"string", - "value":"", - "horizontal":horizontal, - "vertical":verity - }; - if(!q.dataAttributes){ - q.dataAttributes = []; - } - params.id = Utils.newId(); - params.category = "custom"; - if (!temp1.dataShowConfig){ - temp1.dataShowConfig = {}; - if (!temp1.dataShowConfig.value) { - temp1.dataShowConfig.value = []; - } - } - temp1.dataShowConfig.value.push(params); - //Model.updateMulti([q]); - } - } - }, - renderShape: function(q) { - if (q.name == "linker") { - this.renderLinker(q); - return - } - var commonShapeConfig = Utils.copy(Model.define.commonShapeConfig); - var specialShapeConfig; - var attributesJsonArray; - var dataAttributes = q.dataAttributes; - for (var i = 0; i < dataAttributes.length; i++) { - var temp = dataAttributes[i]; - if (temp.hasOwnProperty("attributesJsonArray")) { - if (temp.dataShowConfig) { - specialShapeConfig = temp.dataShowConfig.config; - } - attributesJsonArray = temp.attributesJsonArray; - break; - } - } - var key = q.name; - if (specialShapeConfig == undefined) { - if (commonShapeConfig != undefined && commonShapeConfig[key] != undefined) { - commonShapeConfig = commonShapeConfig[key]; - this.handleShapeConfigData(commonShapeConfig, q, attributesJsonArray); - } - } else { - if (commonShapeConfig == undefined) { - this.handleShapeConfigData(Utils.copy(specialShapeConfig), q, attributesJsonArray); - } else { - commonShapeConfig = commonShapeConfig[key]; - var tempCommonShapeConfig = []; - if (commonShapeConfig != undefined) { - var dataArray = []; - var tempArray = []; - for (i = 0; i < commonShapeConfig.length; i++) { - var temp1 = commonShapeConfig[i]; - for (j = 0; j < specialShapeConfig.length; j++) { - var temp2 = specialShapeConfig[j]; - if (temp1.horizontal == temp2.horizontal && temp1.verity == temp2.verity) { - tempArray.push(i); - break; - } - } - } - if (tempArray.length > 0) { - for (i = 0; i < commonShapeConfig.length; i++) { - if (!(tempArray.indexOf(i) >= 0)) { - tempCommonShapeConfig.push(commonShapeConfig[i]); - } - } - } - } - if (tempCommonShapeConfig.length > 0) { - dataArray = specialShapeConfig.concat(tempCommonShapeConfig); - } else { - dataArray = specialShapeConfig; - } - this.handleShapeConfigData(dataArray, q, attributesJsonArray); - } - } - var o = $("#" + q.id); - if (o.length == 0) { - var v = $("#designer_canvas"); - o = $("
").appendTo(v) - } - var t = Utils.getShapeBox(q); - var w = (t.w + 20).toScale(); - var s = (t.h + 20).toScale(); - o.find(".shape_canvas").attr({ - width: w, - height: s - }); - o.css({ - left: (t.x - 10).toScale() + "px", - top: (t.y - 10).toScale() + "px", - width: w, - height: s - }); - var n = o.find(".shape_canvas")[0].getContext("2d"); - n.clearRect(0, 0, q.props.w + 20, q.props.h + 20); - n.scale(Designer.config.scale, Designer.config.scale); - n.translate(10, 10); - n.translate(q.props.x - t.x, q.props.y - t.y); - n.translate(q.props.w / 2, q.props.h / 2); - n.rotate(q.props.angle); - n.translate( - (q.props.w / 2), -(q.props.h / 2)); - var x = q.lineStyle; - n.globalAlpha = q.shapeStyle.alpha; - n.lineJoin = "round"; - this.renderShapePath(n, q); - this.renderMarkers(n, q); - var m = q.getPath(); - var p = Utils.copy(m[m.length - 1]); - p.fillStyle = { - type: "none" - }; - p.lineStyle = { - lineWidth: 0 - }; - var u = [p]; - this.renderPath(n, q, u); - this.renderText(q, t); - this.renderDataAttributes(q, t); - Designer.painter.renderShapeLink(o, q); //节点链接 - Designer.painter.renderSahpeAttachment(o, q); //节点附件 - if (q.attributesJsonArray != undefined && q.attributesJsonArray.length > 0) { - o.find(".shape_danger").remove(); - o.find(".shape_regulate").remove(); - var A = false; - var z = false; - for (var r in q.attributesJsonArray) { - var l = q.attributesJsonArray[r]; - if (l != undefined && l.key == "danger" && l.value != undefined && l.value != "" && relationShapesObject != undefined) { - if (typeof l.value == 'object' && l.value.constructor == Array) { - for (var m =0; m < l.value.length; m++) { - if (relationShapesObject[l.value[m]] != undefined) { - A = true; - break; - } - } - } else if (relationShapesObject[l.value] != undefined) { - A = true; - } - } else { - if (l != undefined && l.key == "regulate" && l.value != undefined && l.value != "" && relationShapesObject != undefined) { - if (typeof l.value == 'object' && l.value.constructor == Array) { - for (var m =0; m < l.value.length; m++) { - if (relationShapesObject[l.value[m]] != undefined) { - z = true; - break; - } - } - } else if (relationShapesObject[l.value] != undefined) { - z = true; - } - } - } - } - if (A) { - var y = $("
").appendTo(o) - } - // 伊利项目需求 控制角标不显示 - // if (z) { - // var y = $("
").appendTo(o) - // } - } - }, - fillShape: function(n, i, h) { - i.save(); - if (h.type == "solid") { - i.fillStyle = "rgb(" + h.color + ")"; - i.fill() - } else { - if (h.type == "gradient") { - var j; - if (h.gradientType == "linear") { - j = GradientHelper.createLinearGradient(n, i, h) - } else { - j = GradientHelper.createRadialGradient(n, i, h) - } - i.fillStyle = j; - i.fill() - } else { - if (h.type == "image") { - var m = h.fileId; - var k = $(".shape_img[src='" + m + "']"); - if (k.length == 0) { - k = $("").appendTo("#shape_img_container"); - k.bind("load.drawshape", - function() { - var b = (Designer.config.panelItemWidth - n.props.w) / 2; - var a = (Designer.config.panelItemHeight - n.props.h) / 2; - i.translate(b, a); - l(k); - i.restore(); - $(this).attr("loaded", "1") - }); - k.attr("src", m) - } else { - if (k.attr("loaded") == "0") { - k.bind("load.drawshape", - function() { - // var b = (Designer.config.panelItemWidth - n.props.w) / 2; - // var a = (Designer.config.panelItemHeight - n.props.h) / 2; - var b = 0;// by sunlh 20200716 svg shape - var a = 0; - i.translate(b, a); - l(k); - i.restore() - }) - } else { - l(k) - } - } - } - } - } - i.restore(); - function l(r) { - i.save(); - i.clip(); - if (h.display == "fit") { - var d = r.width(); - var q = r.height(); - var a = d / q; - var e = n.props.w / n.props.h; - if (a > e) { - var g = n.props.w; - var b = 0; - var s = g / a; - var c = n.props.h / 2 - s / 2; - i.drawImage(r[0], b, c, g, s) - } else { - var s = n.props.h; - var c = 0; - var g = s * a; - var b = n.props.w / 2 - g / 2; - i.drawImage(r[0], b, c, g, s) - } - } else { - if (h.display == "stretch") { - i.drawImage(r[0], 0, 0, n.props.w, n.props.h) - } else { - if (h.display == "original") { - var d = r.width(); - var q = r.height(); - var b = n.props.w / 2 - d / 2; - var c = n.props.h / 2 - q / 2; - i.drawImage(r[0], b, c, d, q) - } else { - if (h.display == "tile") { - var b = 0; - var d = r.width(); - var q = r.height(); - while (b < n.props.w) { - var c = 0; - while (c < n.props.h) { - i.drawImage(r[0], b, c, d, q); - c += q - } - b += d - } - } else { - if (h.display == "static") { - var u = 0; - var t = r.width(); - var f = r.height(); - i.drawImage(r[0], h.imageX, h.imageY, t, f) - } else { - if (h.display == "zoom") { - var u = 0; - var t = r.width(); - var f = r.height(); - i.drawImage(r[0], h.imageX, h.imageY, t, f, h.canvasX, h.canvasY, h.canvasW, h.canvasH) - } else { - var d = r.width(); - var q = r.height(); - var a = d / q; - var e = n.props.w / n.props.h; - if (a > e) { - var s = n.props.h; - var c = 0; - var g = s * a; - var b = n.props.w / 2 - g / 2; - i.drawImage(r[0], b, c, g, s) - } else { - var g = n.props.w; - var b = 0; - var s = g / a; - var c = n.props.h / 2 - s / 2; - i.drawImage(r[0], b, c, g, s) - } - } - } - } - } - } - } - i.restore() - } - }, - renderText: function(z, r) { - var B = $("#" + z.id); - var v = B.find(".text_canvas[forshape=" + z.id + "]"); - if (v.length == 0) { - v = $("").appendTo(B); - v.bind("focus", - function() { - $(this).blur() - }) - } - v.attr("readonly", "readonly"); - if (z.text == null || z.text.trim() == "") { - v.css({ - height: "0px", - width: "0px" - }).hide(); - return - } - var C = z.fontStyle; - var G = { - "line-height": Math.round(C.size * 1.25) + "px", - "font-size": C.size + "px", - "font-family": C.fontFamily, - "font-weight": C.bold ? "bold": "normal", - "font-style": C.italic ? "italic": "normal", - "text-align": C.textAlign, - color: "rgb(" + C.color + ")", - "text-decoration": C.underline ? "underline": "none", - opacity: z.shapeStyle.alpha - }; - v.css(G); - v.show(); - var s = z.getTextBlock(); - if (z.fontStyle.orientation == "horizontal") { - var D = { - x: s.x + s.w / 2, - y: s.y + s.h / 2 - }; - s = { - x: D.x - s.h / 2, - y: D.y - s.w / 2, - w: s.h, - h: s.w - } - } - v.css({ - width: s.w - }); - v.height(0); - v.val(z.text); - v.scrollTop(99999); - var E = v.scrollTop(); - var y = 0; - if (C.vAlign == "middle") { - y = (s.y + s.h / 2 - E / 2) - } else { - if (z.fontStyle.vAlign == "bottom") { - y = (s.y + s.h - E) - } else { - y = s.y - } - } - var t = { - x: s.x + s.w / 2, - y: y + E / 2 - }; - var w = z.props.angle; - if (w != 0) { - var H = { - x: z.props.w / 2, - y: z.props.h / 2 - }; - t = Utils.getRotated(H, t, w) - } - if (C.orientation == "horizontal") { - w = (Math.PI * 1.5 + w) % (Math.PI * 2) - } - var F = Math.round(w / (Math.PI * 2) * 360); - var x = "rotate(" + F + "deg) scale(" + Designer.config.scale + ")"; - var A = s.w; - var u = E; - v.css({ - width: A, - height: u, - left: (t.x + (z.props.x - r.x) + 10).toScale() - s.w / 2, - top: (t.y + (z.props.y - r.y) + 10).toScale() - E / 2, - "-webkit-transform": x, - "-ms-transform": x, - "-o-transform": x, - "-moz-transform": x, - transform: x - }) - }, - calculateTextLines: function(D, i, z) { - var E = i.w; - var w = i.h; - var J = []; - var H = D.split(/\n/); - for (var x = 0; x < H.length; x++) { - var B = H[x]; - var A = z.measureText(B); - if (A.width <= E) { - J.push(B) - } else { - var C = B.split(/\s/); - var F = ""; - for (var y = 0; y < C.length; y++) { - var j = C[y]; - if (y != C.length - 1) { - j += " " - } - var h = z.measureText(j).width; - if (h > E) { - for (var I = 0; I < j.length; I++) { - var p = F + j[I]; - var G = z.measureText(p).width; - if (G > E) { - J.push(F); - F = j[I] - } else { - F = p - } - } - } else { - var p = F + j; - var G = z.measureText(p).width; - if (G > E) { - J.push(F); - F = j - } else { - F = p - } - } - } - if (F != "") { - J.push(F) - } - } - } - return J - }, - renderMarkers: function(n, r, v) { - if (r.attribute && r.attribute.markers && r.attribute.markers.length > 0) { - var u = r.attribute.markers; - var i = Schema.config.markerSize; - var q = 4; - if (v) { - i = 10 - } - var t = r.attribute.markerOffset; - if (v) { - t = 5 - } - var w = u.length * i + (u.length - 1) * q; - var p = r.props.w / 2 - w / 2; - for (var s = 0; s < u.length; s++) { - var o = u[s]; - n.save(); - n.translate(p, r.props.h - i - t); - var x = Schema.markers[o].call(r, i); - this.renderPath(n, r, x); - n.restore(); - p += i + q - } - } - }, - renderDataAttributes: function(i, k) { - $("#" + i.id).children(".attr_canvas").remove(); - if (!i.dataAttributes || i.dataAttributes.length == 0) { - return - } - var n = { - x: i.props.w / 2, - y: i.props.h / 2 - }; - for (var p = 0; p < i.dataAttributes.length; p++) { - var j = i.dataAttributes[p]; - if (j.hasOwnProperty("attributesJsonArray")) { - if (!j.dataShowConfig) { - continue - } - var jj = j.dataShowConfig.value; - if (jj && jj.length > 0) { - for (var n = 0; n < jj.length; n++) { - var jjj = jj[n]; - var l = ""; - var o = ""; - if (jjj.showName) { - l = j.name + ": " - } - if (jjj.showType == "text" || jjj.showType == "attr") { - l += jjj.value - } else { - if (jjj.showType == "icon") { - o = jjj.icon - } - } - if (l == "" && o == "") { - continue - } - m(jjj, l, o) - } - } - } - /*if (j.showType == "none") { - continue - } - var l = ""; - var o = ""; - if (j.showName) { - l = j.name + ": " - } - if (j.showType == "text" || j.showType == "attr") { - l += j.value - } else { - if (j.showType == "icon") { - o = j.icon - } - } - if (l == "" && o == "") { - continue - } - m(j, l, o)*/ - } - function m(c, y, x) { - var h = c.horizontal; - var I = c.vertical; - var H = $("").appendTo($("#" + i.id)); - var b = H[0].getContext("2d"); - var w = "12px "; - w += i.fontStyle.fontFamily; - b.font = w; - var D = b.measureText(y).width; - var a = 20; - if (x != "") { - D += 20 - } - var E, F; - if (h == "mostleft") { - E = -D - 2 - } else { - if (h == "leftedge") { - E = -D / 2 - } else { - if (h == "left") { - E = 2 - } else { - if (h == "center") { - E = (i.props.w - D) / 2; - } else { - if (h == "right") { - E = i.props.w - D - 2; - if (h == "rightedge") { - E = i.props.w - D / 2 - } else { - E = i.props.w + 2 - } - } - } - } - } - } - if (I == "mosttop") { - F = -a - } else { - if (I == "topedge") { - F = -a / 2 - } else { - if (I == "top") { - F = 0 - } else { - if (I == "middle") { - F = (i.props.h - a) / 2 - } else { - if (I == "bottom") { - F = i.props.h - a - } else { - if (I == "bottomedge") { - F = i.props.h - a / 2 - } else { - F = i.props.h - } - } - } - } - } - } - var g = { - x: E, - y: F, - w: D, - h: a - }; - var G = Utils.getRotatedBox(g, i.props.angle, n); - H.attr({ - width: G.w.toScale(), - height: G.h.toScale() - }); - b.font = w; - var d = (G.x + (i.props.x - k.x) + 10).toScale(); - var e = (G.y + (i.props.y - k.y) + 10).toScale(); - if (h != "mostleft" || h == "left" || h != "right") { - H.css({ - left: d, - top: e - }); - } - b.scale(Designer.config.scale, Designer.config.scale); - b.translate(G.w / 2, G.h / 2); - b.rotate(i.props.angle); - b.translate( - G.w / 2, -G.h / 2); - b.translate((G.w - g.w) / 2, (G.h - g.h) / 2); - b.globalAlpha = i.shapeStyle.alpha; - if (c.type == "link") { - b.fillStyle = "#4183C4" - } else { - b.fillStyle = "#333" - } - if (c.showType == "text") { - b.fillStyle = "#696969"; - } - if (c.showType == "attr") { - b.fillStyle = "#191970"; - } - b.textBaseline = "middle"; - if (D > i.props.w) { - var tempShapeWidth = i.props.w; - if (tempShapeWidth < 100) { - tempShapeWidth = 100; - } - H[0].width = tempShapeWidth + 10; - H[0].height = Math.ceil(D / tempShapeWidth) * 10 + 15; - for (var v = 0; v < Math.ceil(D / tempShapeWidth); v++) { - var tempL = (v + 1) * tempShapeWidth; - var tempX = 0; - if (c.showType == "text") { - b.fillStyle = "#A1A1A1"; - } - if (c.showType == "attr") { - b.fillStyle = "#6666FF"; - } - var tempY = a / 2 + v * 12; - if (tempL < D) { - b.fillText(y.substring(v * tempShapeWidth / (D / y.length), tempL / (D / y.length)), tempX, tempY); - } else { - b.fillText(y.substring(v * tempShapeWidth / (D / y.length), D / (D / y.length)), tempX, tempY); - } - } - if (h == "mostleft") { - d = -tempShapeWidth + tempShapeWidth*0.2; - H.css({ - left: d, - top: e - }); - } - if (h == "left") { - H.css({ - left: d, - top: e - 5 - }); - } - if (h == "left" && I != "bottom") { - H.css({ - left: d, - top: e - }); - } - if (h == "right") { - d = tempShapeWidth / 4; - H.css({ - left: d, - top: e - 5 - }); - } - if (I == "mosttop" || I == "bottom") { - e = e - Math.ceil(D / tempShapeWidth) * 5; - H.css({ - left: d, - top: e - }); - } - if (h == "center" && Math.ceil(D / tempShapeWidth) > 1) { - H.css({ - left: 15, - top: e - }); - } - if (h == "right" && I != "mosttop" && I != "bottom") { - d = tempShapeWidth / 4; - H.css({ - left: d, - top: e - }); - } - } else { - if (h == "mostleft") { - d = -D; - H.css({ - left: d, - top: e - }); - } - if (h == "right") { - d = i.props.w - D; - H.css({ - left: d, - top: e - }); - } - b.fillText(y, 0, a / 2); - } - if (x != "") { - if (x.indexOf("&#x") >= 0) { - var icon = x.split("|")[0]; - var iconColor = x.split("|")[1]; - b.font = "19px awsui-iconfont"; - icon = eval("('"+icon.replace('&#x','\\u').replace(';','')+"')"); - b.fillStyle = iconColor; - b.fillText(icon, 0, a/2); - iconCavCode = H[0].toDataURL("image/png"); - c.iconCavCode = iconCavCode; - } else { - var J = "/images/data-attr/" + x + ".png"; - var f = $(".shape_img[src='" + J + "']"); - if (f.length == 0) { - f = $("").appendTo("#shape_img_container") - } - if (f.attr("loaded") == "true") { - b.drawImage(f[0], g.w - 20, 0, 20, 20) - } else { - f.bind("load.drawshape", - function() { - $(this).attr("loaded", "true"); - b.drawImage(f[0], g.w - 20, 0, 20, 20) - }) - } - } - } - b.beginPath(); - b.rect(0, 0, D, a); - b.closePath() - } - }, - renderLinker: function(h, k) { - if (k) { - h.points = Utils.getLinkerPoints(h) - } - if (h.linkerType == "curve" || h.linkerType == "broken") { - if (!h.points || h.points.length == 0) { - h.points = Utils.getLinkerPoints(h) - } - } - var q = h.points; - var o = Utils.copy(h.from); - var a = Utils.copy(h.to); - if (h.attribute && h.attribute.collapseBy) { - $("#" + h.id).hide(); - return - } else { - $("#" + h.id).show() - } - var p = Utils.getEndpointAngle(h, "from"); - var d = Utils.getEndpointAngle(h, "to"); - var b = Utils.getLinkerLineStyle(h.lineStyle); - l(o, h, b.beginArrowStyle, p); - l(a, h, b.endArrowStyle, d); - var B = a.x; - var x = a.y; - var y = o.x; - var w = o.y; - if (a.x < o.x) { - B = a.x; - y = o.x - } else { - B = o.x; - y = a.x - } - if (a.y < o.y) { - x = a.y; - w = o.y - } else { - x = o.y; - w = a.y - } - for (var r = 0; r < q.length; r++) { - var n = q[r]; - if (n.x < B) { - B = n.x - } else { - if (n.x > y) { - y = n.x - } - } - if (n.y < x) { - x = n.y - } else { - if (n.y > w) { - w = n.y - } - } - } - var f = { - x: B, - y: x, - w: y - B, - h: w - x - }; - var C = $("#" + h.id); - if (C.length == 0) { - var g = $("#designer_canvas"); - C = $("
").appendTo(g) - } - if (!Model.getShapeById(h.id)) { - C.css("z-index", Model.orderList.length + 1) - } - var A = C.find(".shape_canvas"); - A.attr({ - width: (f.w + 20).toScale(), - height: (f.h + 20).toScale() - }); - C.css({ - left: (f.x - 10).toScale(), - top: (f.y - 10).toScale(), - width: (f.w + 20).toScale(), - height: (f.h + 20).toScale() - }); - var m = A[0].getContext("2d"); - m.scale(Designer.config.scale, Designer.config.scale); - m.translate(10, 10); - var s = Utils.getLinkerLineStyle(h.lineStyle); - m.lineWidth = s.lineWidth; - m.strokeStyle = "rgb(" + s.lineColor + ")"; - m.fillStyle = "rgb(" + s.lineColor + ")"; - m.save(); - var z = { - x: o.x - f.x, - y: o.y - f.y - }; - var c = { - x: a.x - f.x, - y: a.y - f.y - }; - m.save(); - if (s.lineStyle == "dashed") { - this.setLineDash(m, [s.lineWidth * 5, s.lineWidth * 2]) - } else { - if (s.lineStyle == "dot") { - this.setLineDash(m, [s.lineWidth, s.lineWidth * 1.5]) - } else { - if (s.lineStyle == "dashdot") { - this.setLineDash(m, [s.lineWidth * 5, s.lineWidth * 2, s.lineWidth, s.lineWidth * 2]) - } - } - } - m.lineJoin = "round"; - m.beginPath(); - this.actions.move.call(m, z); - if (h.linkerType == "curve") { - var v = q[0]; - var u = q[1]; - var t = { - x1: v.x - f.x, - y1: v.y - f.y, - x2: u.x - f.x, - y2: u.y - f.y, - x: c.x, - y: c.y - }; - this.actions.curve.call(m, t) - } else { - for (var r = 0; r < q.length; r++) { - var D = q[r]; - this.actions.line.call(m, { - x: D.x - f.x, - y: D.y - f.y - }) - } - this.actions.line.call(m, c) - } - var j = Utils.isSelected(h.id); - if (j) { - m.shadowBlur = 4; - m.shadowColor = "#833"; - if (h.linkerType == "curve" && Utils.getSelectedIds().length == 1) {} - } - m.stroke(); - m.restore(); - delete m.webkitLineDash; - e(z, p, o.id, s.beginArrowStyle, h, o.angle); - e(c, d, a.id, s.endArrowStyle, h, a.angle); - m.restore(); - this.renderLinkerText(h); - - function l(M, H, i, J) { - if (M.id) { - var E = Model.getShapeById(M.id); - if (E) { - var G = { - x: 0, - y: 0 - }; - var I = Utils.getShapeLineStyle(E.lineStyle); - var L = Utils.getLinkerLineStyle(H.lineStyle); - if (i == "none" || i == "cross") { - G.x = -I.lineWidth / 2 - } else { - if (i == "solidArrow" || i == "dashedArrow") { - G.x = -I.lineWidth / 2 - L.lineWidth * 1.3 - } else { - if (i == "solidDiamond" || i == "dashedDiamond") { - G.x = -I.lineWidth / 2 - L.lineWidth - } else { - G.x = -I.lineWidth / 2 - L.lineWidth / 2 - } - } - } - var K = { - x: 0, - y: 0 - }; - var F = Utils.getRotated(K, G, J); - M.x += F.x; - M.y += F.y - } - } - } - function e(W, M, Q, Y, R, E) { - if (Y == "normal") { - var S = 12; - var ac = Math.PI / 5; - var V = S / Math.cos(ac); - var L = W.x - V * Math.cos(M - ac); - var K = W.y - V * Math.sin(M - ac); - var O = W.x - V * Math.sin(Math.PI / 2 - M - ac); - var N = W.y - V * Math.cos(Math.PI / 2 - M - ac); - m.beginPath(); - m.moveTo(L, K); - m.lineTo(W.x, W.y); - m.lineTo(O, N); - m.stroke() - } else { - if (Y == "solidArrow") { - var S = 12; - var ac = Math.PI / 10; - var V = S / Math.cos(ac); - var L = W.x - V * Math.cos(M - ac); - var K = W.y - V * Math.sin(M - ac); - var O = W.x - V * Math.sin(Math.PI / 2 - M - ac); - var N = W.y - V * Math.cos(Math.PI / 2 - M - ac); - m.beginPath(); - m.moveTo(W.x, W.y); - m.lineTo(L, K); - m.lineTo(O, N); - m.lineTo(W.x, W.y); - m.closePath(); - m.fill(); - m.stroke() - } else { - if (Y == "dashedArrow") { - m.save(); - var S = 12; - var ac = Math.PI / 10; - var V = S / Math.cos(ac); - var L = W.x - V * Math.cos(M - ac); - var K = W.y - V * Math.sin(M - ac); - var O = W.x - V * Math.sin(Math.PI / 2 - M - ac); - var N = W.y - V * Math.cos(Math.PI / 2 - M - ac); - m.beginPath(); - m.moveTo(W.x, W.y); - m.lineTo(L, K); - m.lineTo(O, N); - m.lineTo(W.x, W.y); - m.closePath(); - m.fillStyle = "white"; - m.fill(); - m.stroke(); - m.restore() - } else { - if (Y == "solidCircle") { - m.save(); - var i = 4; - var J = W.x - i * Math.cos(M); - var I = W.y - i * Math.sin(M); - m.beginPath(); - m.arc(J, I, i, 0, Math.PI * 2, false); - m.closePath(); - m.fill(); - m.stroke(); - m.restore() - } else { - if (Y == "dashedCircle") { - m.save(); - var i = 4; - var J = W.x - i * Math.cos(M); - var I = W.y - i * Math.sin(M); - m.beginPath(); - m.arc(J, I, i, 0, Math.PI * 2, false); - m.closePath(); - m.fillStyle = "white"; - m.fill(); - m.stroke(); - m.restore() - } else { - if (Y == "solidDiamond") { - m.save(); - var S = 8; - var ac = Math.PI / 7; - var V = S / Math.cos(ac); - var L = W.x - V * Math.cos(M - ac); - var K = W.y - V * Math.sin(M - ac); - var O = W.x - V * Math.sin(Math.PI / 2 - M - ac); - var N = W.y - V * Math.cos(Math.PI / 2 - M - ac); - var U = W.x - S * 2 * Math.cos(M); - var T = W.y - S * 2 * Math.sin(M); - m.beginPath(); - m.moveTo(W.x, W.y); - m.lineTo(L, K); - m.lineTo(U, T); - m.lineTo(O, N); - m.lineTo(W.x, W.y); - m.closePath(); - m.fill(); - m.stroke(); - m.restore() - } else { - if (Y == "dashedDiamond") { - m.save(); - var S = 8; - var ac = Math.PI / 7; - var V = S / Math.cos(ac); - var L = W.x - V * Math.cos(M - ac); - var K = W.y - V * Math.sin(M - ac); - var O = W.x - V * Math.sin(Math.PI / 2 - M - ac); - var N = W.y - V * Math.cos(Math.PI / 2 - M - ac); - var U = W.x - S * 2 * Math.cos(M); - var T = W.y - S * 2 * Math.sin(M); - m.beginPath(); - m.moveTo(W.x, W.y); - m.lineTo(L, K); - m.lineTo(U, T); - m.lineTo(O, N); - m.lineTo(W.x, W.y); - m.closePath(); - m.fillStyle = "white"; - m.fill(); - m.stroke(); - m.restore() - } else { - if (Y == "cross") { - var H = 6; - var P = 14; - var ab = H * Math.cos(Math.PI / 2 - M); - var aa = H * Math.sin(Math.PI / 2 - M); - var Z = W.x + ab; - var G = W.y - aa; - var U = W.x - P * Math.cos(M); - var T = W.y - P * Math.sin(M); - var X = U - ab; - var F = T + aa; - m.beginPath(); - m.moveTo(Z, G); - m.lineTo(X, F); - m.stroke() - } - } - } - } - } - } - } - } - } - }, - renderLinkerText: function(l) { - var m = $("#" + l.id); - var q = m.find(".text_canvas"); - if (q.length == 0) { - q = $("
").appendTo(m) - } - var n = l.fontStyle; - var p = "scale(" + Designer.config.scale + ")"; - var r = { - "line-height": Math.round(n.size * 1.25) + "px", - "font-size": n.size + "px", - "font-family": n.fontFamily, - "font-weight": n.bold ? "bold": "normal", - "font-style": n.italic ? "italic": "normal", - "text-align": n.textAlign, - color: "rgb(" + n.color + ")", - "text-decoration": n.underline ? "underline": "none", - "-webkit-transform": p, - "-ms-transform": p, - "-o-transform": p, - "-moz-transform": p, - transform: p - }; - q.css(r); - if (l.text == null || l.text == "") { - q.hide(); - return - } - q.show(); - var k = l.text.replace(//g, ">").replace(/\n/g, "
"); - q.html(k + "
"); - var j = this.getLinkerMidpoint(l); - var o = m.position(); - q.css({ - left: j.x.toScale() - o.left - q.width() / 2, - top: j.y.toScale() - o.top - q.height() / 2 - }) - }, - getLinkerMidpoint: function(z) { - var w = {}; - if (z.linkerType == "normal") { - w = { - x: 0.5 * z.from.x + 0.5 * z.to.x, - y: 0.5 * z.from.y + 0.5 * z.to.y - } - } else { - if (z.linkerType == "curve") { - var d = z.from; - var q = z.points[0]; - var v = z.points[1]; - var x = z.to; - w = { - x: d.x * 0.125 + q.x * 0.375 + v.x * 0.375 + x.x * 0.125, - y: d.y * 0.125 + q.y * 0.375 + v.y * 0.375 + x.y * 0.125 - } - } else { - var u = []; - u.push(z.from); - u = u.concat(z.points); - u.push(z.to); - var r = 0; - for (var A = 1; A < u.length; A++) { - var q = u[A - 1]; - var v = u[A]; - var y = Utils.measureDistance(q, v); - r += y - } - var s = r / 2; - var B = 0; - for (var A = 1; A < u.length; A++) { - var q = u[A - 1]; - var v = u[A]; - var y = Utils.measureDistance(q, v); - var t = B + y; - if (t > s) { - var p = (s - B) / y; - w = { - x: (1 - p) * q.x + p * v.x, - y: (1 - p) * q.y + p * v.y - }; - break - } - B = t - } - } - } - return w - }, - controlStatus: { - resizeDir: [], - rotatable: true - }, - drawControls: function(m) { - var n = $("#shape_controls"); - if (n.length == 0) { - var r = $("#designer_canvas"); - n = $("
").appendTo(r); - n.append(""); - n.append("
"); - n.append("
"); - n.append("
"); - n.append("
"); - n.append("
"); - n.append("
"); - n.append("
"); - n.append("
"); - Designer.op.shapeResizable(); - n.append(""); - Designer.op.shapeRotatable(); - n.append("
"); - Designer.op.groupShapeChangable(); - $(".shape_controller").css({ - "border-color": Designer.config.anchorColor, - width: Designer.config.anchorSize - 2, - height: Designer.config.anchorSize - 2 - }) - } - $(".shape_controller").css({ - "z-index": Model.orderList.length - }); - $(".change_shape_icon").hide(); - n.show(); - var p = 0; - var i; - var q; - if (m.length == 1) { - var l = Model.getShapeById(m[0]); - i = l.props; - p = l.props.angle; - q = l.resizeDir; - if (l.groupName && SchemaGroup.groupExists(l.groupName)) { - $(".change_shape_icon").show() - } - } else { - i = Utils.getControlBox(m); - q = ["tl", "tr", "br", "bl"] - } - var t = true; - for (var o = 0; o < m.length; o++) { - var s = m[o]; - var l = Model.getShapeById(s); - if (l.attribute && l.attribute.rotatable == false) { - t = false - } - if ((l.resizeDir && l.resizeDir.length == 0) || (l.parent && m.length > 1)) { - q = [] - } - } - this.controlStatus.rotatable = t; - this.controlStatus.resizeDir = q; - this.rotateControls(i, p); - return n - }, - rotateControls: function(R, E) { - var O = $("#shape_controls"); - var N = Utils.getRotatedBox(R, E); - var i = N.w.toScale(); - var Q = N.h.toScale(); - O.css({ - left: N.x.toScale(), - top: N.y.toScale(), - width: i, - height: Q, - "z-index": Model.orderList.length - }); - var P = i + 20; - var K = Q + 20; - var S = $("#controls_bounding"); - S.attr({ - width: P, - height: K - }); - var J = S[0].getContext("2d"); - J.lineJoin = "round"; - if (this.controlStatus.resizeDir.length == 0) { - J.lineWidth = 2; - J.strokeStyle = Designer.config.selectorColor; - J.globalAlpha = 0.8 - } else { - J.lineWidth = 1; - J.strokeStyle = Designer.config.selectorColor; - J.globalAlpha = 0.5 - } - J.save(); - J.clearRect(0, 0, P, K); - J.translate(P / 2, K / 2); - J.rotate(E); - J.translate( - P / 2, -K / 2); - J.translate(9.5, 9.5); - var W = { - x: Math.round((R.x - N.x).toScale()), - y: Math.round((R.y - N.y).toScale()), - w: Math.floor(R.w.toScale() + 1), - h: Math.floor(R.h.toScale() + 1) - }; - J.strokeRect(W.x, W.y, W.w, W.h); - J.restore(); - var A = 0 - Designer.config.anchorSize / 2; - var G = {}; - R = Utils.toScale(R); - N = Utils.toScale(N); - var D = { - x: (R.x + R.w / 2), - y: R.y + R.h / 2 - }; - O.children(".shape_controller").hide(); - for (var H = 0; H < this.controlStatus.resizeDir.length; H++) { - var L = this.controlStatus.resizeDir[H]; - var X = $(".shape_controller[resizeDir=" + L + "]"); - X.show(); - var U, V; - if (L.indexOf("l") >= 0) { - U = R.x - } else { - if (L.indexOf("r") >= 0) { - U = R.x + R.w - } else { - U = R.x + R.w / 2 - } - } - if (L.indexOf("t") >= 0) { - V = R.y - } else { - if (L.indexOf("b") >= 0) { - V = R.y + R.h - } else { - V = R.y + R.h / 2 - } - } - var T = Utils.getRotated(D, { - x: U, - y: V - }, - E); - X.css({ - left: T.x - N.x + A, - top: T.y - N.y + A - }) - } - var M = Math.PI / 8; - O.children(".shape_controller").removeClass("s n e w"); - if (E > M && E <= M * 3) { - O.children("div[resizeDir=tl]").addClass("n"); - O.children("div[resizeDir=tr]").addClass("e"); - O.children("div[resizeDir=br]").addClass("s"); - O.children("div[resizeDir=bl]").addClass("w"); - O.children("div[resizeDir=l]").addClass("n w"); - O.children("div[resizeDir=r]").addClass("s e"); - O.children("div[resizeDir=b]").addClass("s w"); - O.children("div[resizeDir=t]").addClass("n e") - } else { - if (E > M * 3 && E <= M * 5) { - O.children("div[resizeDir=tl]").addClass("n e"); - O.children("div[resizeDir=tr]").addClass("s e"); - O.children("div[resizeDir=br]").addClass("s w"); - O.children("div[resizeDir=bl]").addClass("n w"); - O.children("div[resizeDir=l]").addClass("n"); - O.children("div[resizeDir=r]").addClass("s"); - O.children("div[resizeDir=b]").addClass("w"); - O.children("div[resizeDir=t]").addClass("e") - } else { - if (E > M * 5 && E <= M * 7) { - O.children("div[resizeDir=tl]").addClass("e"); - O.children("div[resizeDir=tr]").addClass("s"); - O.children("div[resizeDir=br]").addClass("w"); - O.children("div[resizeDir=bl]").addClass("n"); - O.children("div[resizeDir=l]").addClass("n e"); - O.children("div[resizeDir=r]").addClass("s w"); - O.children("div[resizeDir=b]").addClass("n w"); - O.children("div[resizeDir=t]").addClass("s e") - } else { - if (E > M * 7 && E <= M * 9) { - O.children("div[resizeDir=tl]").addClass("s e"); - O.children("div[resizeDir=tr]").addClass("s w"); - O.children("div[resizeDir=br]").addClass("n w"); - O.children("div[resizeDir=bl]").addClass("n e"); - O.children("div[resizeDir=l]").addClass("e"); - O.children("div[resizeDir=r]").addClass("w"); - O.children("div[resizeDir=b]").addClass("n"); - O.children("div[resizeDir=t]").addClass("s") - } else { - if (E > M * 9 && E <= M * 11) { - O.children("div[resizeDir=tl]").addClass("s"); - O.children("div[resizeDir=tr]").addClass("w"); - O.children("div[resizeDir=br]").addClass("n"); - O.children("div[resizeDir=bl]").addClass("e"); - O.children("div[resizeDir=l]").addClass("s e"); - O.children("div[resizeDir=r]").addClass("n w"); - O.children("div[resizeDir=b]").addClass("n e"); - O.children("div[resizeDir=t]").addClass("s w") - } else { - if (E > M * 11 && E <= M * 13) { - O.children("div[resizeDir=tl]").addClass("s w"); - O.children("div[resizeDir=tr]").addClass("n w"); - O.children("div[resizeDir=br]").addClass("n e"); - O.children("div[resizeDir=bl]").addClass("s e"); - O.children("div[resizeDir=l]").addClass("s"); - O.children("div[resizeDir=r]").addClass("n"); - O.children("div[resizeDir=b]").addClass("e"); - O.children("div[resizeDir=t]").addClass("w") - } else { - if (E > M * 13 && E <= M * 15) { - O.children("div[resizeDir=tl]").addClass("w"); - O.children("div[resizeDir=tr]").addClass("n"); - O.children("div[resizeDir=br]").addClass("e"); - O.children("div[resizeDir=bl]").addClass("s"); - O.children("div[resizeDir=l]").addClass("s w"); - O.children("div[resizeDir=r]").addClass("n e"); - O.children("div[resizeDir=b]").addClass("s e"); - O.children("div[resizeDir=t]").addClass("n w") - } else { - O.children("div[resizeDir=tl]").addClass("n w"); - O.children("div[resizeDir=tr]").addClass("n e"); - O.children("div[resizeDir=br]").addClass("s e"); - O.children("div[resizeDir=bl]").addClass("s w"); - O.children("div[resizeDir=l]").addClass("w"); - O.children("div[resizeDir=r]").addClass("e"); - O.children("div[resizeDir=b]").addClass("s"); - O.children("div[resizeDir=t]").addClass("n") - } - } - } - } - } - } - } - if (this.controlStatus.rotatable) { - var B = O.find(".shape_rotater"); - B.show(); - var C = { - x: R.x + R.w / 2, - y: R.y - 20 - }; - var F = Utils.getRotated(D, C, E); - B.css({ - top: F.y - 20 - N.y, - left: F.x - 20.5 - N.x - }); - var I = B[0].getContext("2d"); - I.lineWidth = 1; - I.strokeStyle = Designer.config.selectorColor; - I.fillStyle = "white"; - I.save(); - I.clearRect(0, 0, 41, 40); - I.translate(20.5, 20); - I.rotate(E); - I.translate( - 20.5, -20); - I.beginPath(); - I.moveTo(20.5, 20); - I.lineTo(20.5, 40); - I.stroke(); - I.beginPath(); - I.arc(20.5, 20, Designer.config.rotaterSize / 2, 0, Math.PI * 2); - I.closePath(); - I.fill(); - I.stroke(); - I.restore() - } else { - O.find(".shape_rotater").hide() - } - }, - renderShapeLink : function(o, q) { - //图形的链接 - o.find(".shape_link_point").remove(); - if (q.link) { - var y = $("").appendTo(o); - y.on("mousedown.link", - function(I) { - I.stopPropagation(); - var c = Model.getShapeById($(this).parent().attr("id")); - myshapeLink = c; - if (c != undefined) { - var k = c.props.x; - var j = c.props.y; - var B = c.props.w; - var H = c.props.h; - var b = $("#link-dialog-normal_contextmenu"); - b.empty(); - var D = []; - for (var G = 0; G < c.dataAttributes.length; G++) { - var E = c.dataAttributes[G]; - if (E.linksArray) { - D = E.linksArray; - break - } - } - var d = ""; - for (var f = 0; f < D.length; f++) { - if (D[f].type == "file") { - d += D[f].uuid + "," - } - } - if (D.length > 0 && window.opener) { - var a = parent.window.$("#appId").val(); - var K = { - sid: $("#sid").val(), - cmd: "com.actionsoft.apps.coe.pal_pl_repository_designer_viewer_link_perm", - uuids: d, - filePerms: filePerms - }; - if (window.opener) { - K.modelType = "used" - } else { - if (a != undefined && a != "com.actionsoft.apps.coe.pal" && a != "") { - K.modelType = "published" - } - } - awsui.ajax.request({ - url: "./jd", - method: "POST", - data: K, - async: false, - ok: function(L) { - var N = []; - var M = L.data.uuids; - // M = M.split(","); - for (var e = 0; e < D.length; e++) { - var h = false; - var i = D[e].uuid; - if (D[e].type == "file") { - for (var O = 0; O < M.length; O++) { - if (M[O].linkUUID == D[e].uuid) { - h = true; - break - } - } - } else { - h = true - } - if (h) { - D[e].uuid = i; - N.push(D[e]) - } - } - D = N - } - }) - } - if (D.length == 0) { - b.hide(); - $.simpleAlert("没有链接权限", "error"); - return - } else { - if (D.length == 1) { - b.hide(); - openLinkUrlRewrite(D[0].type, D[0].url, D[0].target, D[0].uuid, "", D[0].name, true); - return - } else { - for (var f = 0; f < D.length; f++) { - linkIndex++; - var C = D[f]; - var F = '
  • " + C.name + ""; - if (role == "owner") { - F += '
    删除
    " - } - F += "
  • "; - b.append(F) - } - } - } - var g = Utils.getShapeByPosition(k, j, false); - var J = Designer.clipboard.elements.length; - if (g == null) { - if (J > 0) { - b.children("li[ac=paste]").show(); - b.children(".devi_clip").show() - } - } else { - var c = g.shape; - b.children("li[ac=cut]").show() - } - b.css({ - display: "block", - "z-index": Model.orderList.length + 3, - left: k + B + 10, - top: j + H - }); - $(document).on("mousedown.link", ":not(#link-dialog-normal_contextmenu li):not(#link-dialog-normal_contextmenu ul):not(#link-dialog-normal_contextmenu a):not(#link-dialog-normal_contextmenu div)", - function(h) { - if (this.id == "link-dialog-normal_contextmenu") { - return false - } - b.hide() - }) - } - I.stopPropagation() - }) - } - }, - renderSahpeAttachment: function(o, q) { - // 图形的附件 - o.find(".shape_attachment_point").remove(); - var selflist = []; //自身附件 - var relatelist = []; //关联附件 - var reqComplete = false; //是否请求完成 - // 封装请求后台方法.参数控制是否异步请求 - var reqMethod_renderSahpeAttachment = function(isAsync) { - // 请求后台的自身附件 - $.ajax({ - method: "POST", - async: isAsync, - url: "./jd?sid=" + encodeURIComponent(sid) + "&cmd=com.actionsoft.apps.coe.pal_processlevel_upfile_load", - data: {pl_uuid: ruuid, uuids: q.id}, - success: function(msg) { - selflist = msg.data.list; - // 请求后台的关联附件 - $.ajax({ - method: "POST", - async: isAsync, - url: "./jd?sid=" + encodeURIComponent(sid) + "&cmd=com.actionsoft.apps.coe.pal_processlevel_relation_upfile_load", - data: {pl_uuid: ruuid, shape_uuid: q.id}, - success: function(msg) { - relatelist = msg.data.list; - reqComplete = true; - } - }); - } - }); - }; - // 使用请求 - reqMethod_renderSahpeAttachment(true); - // 使用定时器,异步控制节点的附件角标的出现 - var startTime = new Date().getTime(); - var intervalClr = window.setInterval(function(){ - // 5秒内请求完毕则处理,5秒内请求不完则不再处理 - var endTime = new Date().getTime(); - if(endTime - startTime > 5000 || reqComplete == true) { - // 取消此定时器 - window.clearInterval(intervalClr); - // 图形有附件,增加右下角图标 --begin - if ( (selflist && selflist.length > 0) || (relatelist && relatelist.length > 0) ) { - var y = $("
    " + - "" + - "
    ").appendTo(o); - //将此节点的z-index置于靠顶的位置,以便鼠标可以点击到 - /*当连线挡住节点导致不能点击时,置于顶层,但此时每次进入设计器都会提示设计器已修改 - var start = Model.maxZIndex + 1; - q.props.zindex = start; //q为当前shape - Model.updateMulti([q]);*/ - // 重画节点 Designer.painter.renderShape(q); - y.on("mousedown.attachment", - function(I) { - I.stopPropagation(); - // 每次点击节点附件下标再次请求后台,使用最新附件列表 - reqMethod_renderSahpeAttachment(false); - var c = Model.getShapeById($(this).parent().attr("id")); //设计器上的图形 - myshapeLink = c; - if (c != undefined) { - var k = c.props.x; - var j = c.props.y; - var B = c.props.w; - var H = c.props.h; - var b = $("#attachment-dialog-normal_contextmenu"); - b.empty(); - b.append(''); //用于提供下载窗口 - for(var s = 0; s < 2; s++) { //循环附件和关联附件 - var attalist = selflist; //统一处理附件或者关联附件 - var attaTypeName = "附件"; //附件or关联附件 - if(s==0) { //自身附件 - // - } else { //关联附件 - attalist = relatelist; - attaTypeName = "关联附件"; - } - if(attalist.length > 0) { - b.append('
  • ' + attaTypeName + '
  • '); - for(var f = 0; f < attalist.length; f++) { - var atta = attalist[f]; - // 是否允许下载的逻辑判断 1.支持下载 or 2.当前用户为上传用户 or admin用户 - var createUser = atta.createUser; - var download = atta.download; - var downloadPerm = false; - if(s==0) { - // 附件 可以下载的条件: 1.支持下载 2.当前用户为上传用户 - if(download == 1 || user == createUser) { - downloadPerm = true; - } - } else { - // 关联附件 可以下载的条件: 1.支持下载 - if(download == 1) { - downloadPerm = true; - } - } - // 拼接展示框 - var F = '
  • ' + atta.fileName + ''; - if( downloadPerm ) { - F += '
    下载
    '; - } - F += "
  • "; - b.append(F) - } - } - } - // 如果其他人操作致使没有附件可展示,则给出无附件的展示 - if(selflist.length == 0 && relatelist.length == 0) { - b.append('
  • ' + '无附件' + '
  • '); - } - // 控制展示与否 - var g = Utils.getShapeByPosition(k, j, false); - var J = Designer.clipboard.elements.length; - if (g == null) { - if (J > 0) { - b.children("li[ac=paste]").show(); - b.children(".devi_clip").show() - } - } else { - var c = g.shape; - b.children("li[ac=cut]").show() - } - b.css({ - display: "block", - "z-index": Model.orderList.length + 3, - left: k + B + 10, - top: j + H - }); - $(document).on("mousedown.attachment", ":not(#attachment-dialog-normal_contextmenu span):not(#attachment-dialog-normal_contextmenu li):not(#attachment-dialog-normal_contextmenu ul):not(#attachment-dialog-normal_contextmenu a):not(#attachment-dialog-normal_contextmenu div)", - function(h) { - if (this.id == "attachment-dialog-normal_contextmenu") { - return false; - } - b.hide(); - }); - } - I.stopPropagation() - }); - } - // 图形有附件,增加右下角图标 --end - } - },100); // end setInterval - }, // end renderSahpeAttachment - } -}; -var Model = { - define: {}, - persistence: {}, - orderList: [], - maxZIndex: 0, - linkerMap: { - map: {}, - add: function(c, d) { - if (!this.map[c]) { - this.map[c] = [] - } - if (this.map[c].indexOf(d) < 0) { - this.map[c].push(d) - } - }, - remove: function(c, d) { - if (this.map[c]) { - Utils.removeFromArray(this.map[c], d) - } - }, - empty: function() { - this.map = {} - } - }, - groupMap: { - map: {}, - add: function(d, c) { - this.map[d] = c - }, - push: function(d, c) { - if (!this.map[d]) { - this.map[d] = [] - } - this.map[d].push(c) - }, - remove: function(b) { - delete this.map[b] - }, - empty: function() { - this.map = {} - } - }, - create: function(l, h, j) {// designer.extend.core.js重写 - var m = Utils.newId(); - var o = Utils.copy(Schema.shapes[l]); - o.id = m; - o.props.x = h; - o.props.y = j; - o.props.zindex = Model.maxZIndex + 1; - o.props = $.extend(true, {}, - Schema.shapeDefaults.props, o.props); - for (var k = 0; k < o.dataAttributes.length; k++) { - var i = o.dataAttributes[k]; - i.id = Utils.newId(); - if (i.attributesJsonArray) { - if (Model.define.localAttribute != undefined && Model.define.localAttribute[o.name] != undefined && Model.define.localAttribute[o.name] != null && Model.define.localAttribute[o.name].length > 0) { - for (var n in Model.define.localAttribute[o.name]) { - i.attributesJsonArray.push(Utils.copy(Model.define.localAttribute[o.name][n])); - } - } - } - } - Designer.events.push("create", o); - return o - }, - add: function(d, c) { - this.addMulti([d], c) - }, - addMulti: function(f, h) { - if (typeof h == "undefined") { - h = true - } - var g = []; - for (var i = 0; i < f.length; i++) { - var j = f[i]; - g.push(Utils.copy(j)); - this.define.elements[j.id] = Utils.copy(j); - this.persistence.elements[j.id] = Utils.copy(j) - } - this.build(); - if (h) { - MessageSource.send("create", g) - } - }, - update: function(b) { - this.updateMulti([b]); - Designer.painter.renderShape(b) - }, - updateMulti: function(l) { - var h = []; - var g = []; - for (var j = 0; j < l.length; j++) { - var k = l[j]; - if (this.define.elements[k.id]) { - this.define.elements[k.id] = Utils.copy(k); - g.push(Utils.copy(this.getPersistenceById(k.id))); - h.push(Utils.copy(k)); - this.persistence.elements[k.id] = Utils.copy(k) - } - } - this.build(); - var i = { - shapes: g, - updates: h - }; - MessageSource.send("update", i) - }, - remove: function(C, u) { - if (typeof u == "undefined") { - u = true - } - if (u) { - C = Designer.events.push("beforeRemove", C) - } - var w = []; - var r = []; - var z = []; - var q = []; - var A = []; - if (C.length == 0) { - return false - } - for (var y = 0; y < C.length; y++) { - var v = C[y]; - if (v.name == "linker") { - A.push(v.id) - } else { - q.push(v.id) - } - } - for (var y = 0; y < C.length; y++) { - var v = C[y]; - w.push(Utils.copy(v)); - $("#" + v.id).remove(); - delete this.define.elements[v.id]; - delete this.persistence.elements[v.id]; - this.groupMap.remove(v.group); - if (v.name == "linker") { - if (v.from.id != null) { - this.linkerMap.remove(v.from.id, v.id) - } - if (v.to.id != null) { - this.linkerMap.remove(v.to.id, v.id) - } - } else { - if (v.parent && q.indexOf(v.parent) < 0) { - var t = Model.getShapeById(v.parent); - if (t) { - Utils.removeFromArray(t.children, v.id); - if (r.indexOf(v.parent) < 0) { - r.push(v.parent); - z.push(t) - } - } - } - var i = this.getShapeLinkers(v.id); - if (i && i.length > 0) { - for (var x = 0; x < i.length; x++) { - var D = i[x]; - if (A.indexOf(D) < 0) { - var B = this.getShapeById(D); - if (B.from.id != null && B.from.id == v.id) { - B.from.id = null; - B.from.angle = null - } - if (B.to.id != null && B.to.id == v.id) { - B.to.id = null; - B.to.angle = null - } - if (r.indexOf(D) < 0) { - r.push(D); - z.push(B) - } - } - } - } - delete this.linkerMap.map[v.id] - } - } - this.build(); - MessageSource.beginBatch(); - MessageSource.send("remove", w); - if (u) { - var s = Designer.events.push("removed", { - shapes: C, - changedIds: r, - range: q - }); - if (s && s.length) { - z = z.concat(s) - } - } - if (z.length > 0) { - this.updateMulti(z) - } - MessageSource.commit(); - return true - }, - updatePage: function(f, h) { - var e = $.extend(Model.define.page, f); - var g = { - page: Utils.copy(Model.persistence.page), - update: Utils.copy(e) - }; - Model.persistence.page = Utils.copy(e); - MessageSource.send("updatePage", g); - Designer.initialize.initCanvas() - }, - updateLocalAttribute: function(e) { - var c = $.extend(Model.define.localAttribute, e); - var f = { - localAttribute: Utils.copy(Model.persistence.localAttribute), - update: Utils.copy(c) - }; - Model.persistence.localAttribute = Utils.copy(c); - MessageSource.send("updateLocalAttribute", f) - }, - getShapeById: function(b) { - return this.define.elements[b] - }, - getPersistenceById: function(b) { - return this.persistence.elements[b] - }, - build: function() { - this.orderList = []; - this.linkerMap.empty(); - for (var h in Model.define.elements) { - var g = Model.getShapeById(h); - this.orderList.push({ - id: g.id, - zindex: g.props.zindex - }); - if (g.name == "linker") { - if (g.from.id != null) { - this.linkerMap.add(g.from.id, g.id) - } - if (g.to.id != null) { - this.linkerMap.add(g.to.id, g.id) - } - } - if (g.group) { - this.groupMap.push(g.group, g.id) - } - } - this.orderList.sort(function i(a, b) { - return a.zindex - b.zindex; - }); - for (var j = 0; j < Model.orderList.length; j++) { - var h = Model.orderList[j].id; - var g = Model.getShapeById(h); - $("#" + h).css("z-index", j); - } - var f = 0; - if (this.orderList.length > 0) { - f = this.orderList[this.orderList.length - 1].zindex - } - this.maxZIndex = f - }, - getShapeLinkers: function(b) { - return this.linkerMap.map[b] - }, - getGroupShapes: function(b) { - return this.groupMap.map[b] - }, - changeShape: function(e, f) { - var d = Schema.shapes[f]; - e.name = f; - e.title = d.shapeName; - e.attribute = d.attribute; - e.dataAttributes = d.dataAttributes; - e.path = d.path; - e.textBlock = d.textBlock; - e.anchors = d.anchors; - Schema.initShapeFunctions(e); - Designer.painter.renderShape(e) - } -}; -var Utils = { - getDomById: function(b) { - return document.getElementById(b) - }, - newId: function() { - var c = Math.random(); - var d = (c + new Date().getTime()); - return d.toString(16).replace(".", "") - }, - getShapeByPosition: function(V, W, ab) { - var at = []; - for (var x = Model.orderList.length - 1; x >= 0; x--) { - var S = Model.orderList[x].id; - var i = $("#" + S); - var am = Model.getShapeById(S); - var ak = i.position(); - var ac = V - ak.left; - var ad = W - ak.top; - var R = { - x: ak.left, - y: ak.top, - w: i.width(), - h: i.height() - }; - var y = i.find(".shape_canvas")[0]; - var av = y.getContext("2d"); - var aB = this.pointInRect(V, W, R); - if (am.name == "linker") { - if (!aB) { - continue - } - if (ab) { - continue - } - var U = 10; - U = U.toScale(); - var ae = { - x: V - U, - y: W - U, - w: U * 2, - h: U * 2 - }; - if (this.pointInRect(am.to.x.toScale(), am.to.y.toScale(), ae)) { - var al = { - type: "linker_point", - point: "end", - shape: am - }; - at.push(al); - - } else { - if (this.pointInRect(am.from.x.toScale(), am.from.y.toScale(), ae)) { - var al = { - type: "linker_point", - point: "from", - shape: am - }; - at.push(al); - - } else { - var aj = i.find(".text_canvas"); - var ah = aj.position(); - var ae = { - x: ah.left, - y: ah.top, - w: aj.width(), - h: aj.height() - }; - if (this.pointInRect(ac, ad, ae)) { - var al = { - type: "linker_text", - shape: am - }; - at.push(al); - continue - } - U = 7; - U = U.toScale(); - var ag = this.pointInLinker({ - x: V.restoreScale(), - y: W.restoreScale() - }, - am, U); - if (ag > -1) { - var al = { - type: "linker", - shape: am, - pointIndex: ag - }; - at.push(al); - - } - } - } - } else { - if (aB && am.locked && !ab) { - if (av.isPointInPath(ac, ad)) { - var al = { - type: "shape", - shape: am - }; - at.push(al) - } - continue - } - var U = 7; - if (aB) { - U = U.toScale(); - var ae = { - x: V - U, - y: W - U, - w: U * 2, - h: U * 2 - }; - var Z = { - x: am.props.x + am.props.w / 2, - y: am.props.y + am.props.h / 2 - }; - var ao = am.getAnchors(); - var al = null; - for (var aw = 0; aw < ao.length; aw++) { - var ay = ao[aw]; - ay = this.getRotated(Z, { - x: am.props.x + ay.x, - y: am.props.y + ay.y - }, - am.props.angle); - if (Utils.pointInRect(ay.x.toScale(), ay.y.toScale(), ae)) { - var an = Utils.getPointAngle(S, ay.x, ay.y, U); - ay.angle = an; - al = { - type: "bounding", - shape: am, - linkPoint: ay - }; - if (av.isPointInPath(ac, ad)) { - al.inPath = true - } - break - } - } - if (al != null) { - at.push(al); - continue - } - } - if (am.dataAttributes) { - var al = null; - for (var au = 0; au < am.dataAttributes.length; au++) { - var ap = am.dataAttributes[au]; - if (ap.type == "link" && ap.showType && ap.showType != "none") { - var af = i.children("#attr_canvas_" + ap.id); - if (af.length > 0) { - var ai = af.position(); - var X = ac - ai.left; - var Y = ad - ai.top; - var ar = af[0].getContext("2d"); - if (ar.isPointInPath(X, Y)) { - al = { - type: "dataAttribute", - shape: am, - attribute: ap - }; - break - } - } - } - } - if (al != null) { - at.push(al); - continue - } - } - if (!aB) { - continue - } - if (av.isPointInPath(ac, ad)) { - if (ab) { - var ao = am.getAnchors(); - if (ao && ao.length) { - var al = { - type: "shape", - shape: am - }; - at.push(al); - - } else { - - } - } else { - var al = { - type: "shape", - shape: am - }; - at.push(al); - - } - } else { - if (!am.attribute || typeof am.attribute.linkable == "undefined" || am.attribute.linkable) { - var an = Utils.getPointAngle(S, V.restoreScale(), W.restoreScale(), U); - if (an != null) { - var al = null; - var aC = { - angle: an - }; - for (var aa = 1; aa <= U; aa++) { - if (an == 0) { - aC.x = ac + aa; - aC.y = ad - } else { - if (an < Math.PI / 2) { - aC.x = ac + aa * Math.cos(an); - aC.y = ad + aa * Math.sin(an) - } else { - if (an == Math.PI / 2) { - aC.x = ac; - aC.y = ad + aa - } else { - if (an < Math.PI) { - aC.x = ac - aa * Math.sin(an - Math.PI / 2); - aC.y = ad + aa * Math.cos(an - Math.PI / 2) - } else { - if (an == Math.PI / 2) { - aC.x = ac - aa; - aC.y = ad - } else { - if (an < Math.PI / 2 * 3) { - aC.x = ac - aa * Math.cos(an - Math.PI); - aC.y = ad - aa * Math.sin(an - Math.PI) - } else { - if (an == Math.PI / 2 * 3) { - aC.x = ac; - aC.y = ad - aa - } else { - aC.x = ac + aa * Math.sin(an - Math.PI / 2 * 3); - aC.y = ad - aa * Math.cos(an - Math.PI / 2 * 3) - } - } - } - } - } - } - } - if (av.isPointInPath(aC.x, aC.y)) { - aC.x += ak.left; - aC.y += ak.top; - aC.x = aC.x.restoreScale(); - aC.y = aC.y.restoreScale(); - al = { - type: "bounding", - shape: am, - linkPoint: aC - }; - break - } - } - if (al != null) { - at.push(al); - - } - } - } - } - } - } - var al = null; - if (at.length == 1) { - al = at[0] - } - if (at.length > 1 && ab) { - al = at[0] - } else { - if (at.length > 1) { - var ax = at[0]; - if (ax.type == "bounding" && ax.type != "linker_point" && ax.type != "linker") { - return ax - } - var ag = []; - var aA = []; - var aq = []; - for (var x = 0; x < at.length; x++) { - var T = at[x]; - if (T.type == "bounding") { - aq.push(T) - } else { - if (T.type == "linker") { - ag.push(T) - } else { - if (T.type == "linker_point") { - aA.push(T) - } - } - } - } - if (aq.length > 0 && aA.length > 0) { - for (var x = 0; x < aq.length; x++) { - var T = aq[x]; - if (T.inPath) { - al = T; - break - } - } - } - if (al == null && aA.length > 0) { - aA.sort(function az(a, b) { - if (Utils.isSelected(a.shape.id) && !Utils.isSelected(b.shape.id)) { - return - 1 - } else { - if (!Utils.isSelected(a.shape.id) && Utils.isSelected(b.shape.id)) { - return 1 - } else { - return b.shape.props.zindex - a.shape.props.zindex - } - } - }); - al = aA[0] - } - if (al == null && ag.length > 0) { - ag.sort(function az(a, b) { - if (Utils.isSelected(a.shape.id) && !Utils.isSelected(b.shape.id)) { - return - 1 - } else { - if (!Utils.isSelected(a.shape.id) && Utils.isSelected(b.shape.id)) { - return 1 - } else { - return b.shape.props.zindex - a.shape.props.zindex - } - } - }); - al = ag[0] - } - if (al == null) { - al = at[0] - } - } - } - return al - }, - checkCross: function(k, m, n, o) { - var j = false; - var l = (m.x - k.x) * (o.y - n.y) - (m.y - k.y) * (o.x - n.x); - if (l != 0) { - var p = ((k.y - n.y) * (o.x - n.x) - (k.x - n.x) * (o.y - n.y)) / l; - var d = ((k.y - n.y) * (m.x - k.x) - (k.x - n.x) * (m.y - k.y)) / l; - if ((p >= 0) && (p <= 1) && (d >= 0) && (d <= 1)) { - j = true - } - } - return j - }, - rectCross: function(m, n) { - var q = m.x; - var o = m.x + m.w; - var k = m.y; - var s = m.y + m.h; - var r = n.x; - var p = n.x + n.w; - var l = n.y; - var t = n.y + n.h; - if (((q < p) && (r < o)) && ((k < t) && (l < s))) { - return true - } else { - return false - } - }, - rectInRect: function(l, h) { - var i = { - x: l.x, - y: l.y - }; - var j = { - x: l.x + l.w, - y: l.y - }; - var k = { - x: l.x + l.w, - y: l.y + l.h - }; - var g = { - x: l.x, - y: l.y + l.h - }; - if (this.pointInRect(i.x, i.y, h) && this.pointInRect(j.x, j.y, h) && this.pointInRect(k.x, k.y, h) && this.pointInRect(g.x, g.y, h)) { - return true - } else { - return false - } - }, - pointInPolygon: function(j, p) { - var k, l, m, n; - k = j; - l = { - x: -1000000, - y: j.y - }; - var o = 0; - for (var i = 0; i < p.length - 1; i++) { - m = p[i]; - n = p[i + 1]; - if (Utils.checkCross(k, l, m, n) == true) { - o++ - } - } - m = p[p.length - 1]; - n = p[0]; - if (Utils.checkCross(k, l, m, n) == true) { - o++ - } - return (o % 2 == 0) ? false: true - }, - pointInRect: function(d, e, f) { - if (d >= f.x && d <= f.x + f.w && e >= f.y && e <= f.y + f.h) { - return true - } - return false - }, - pointInLinker: function(q, t, s) { - var o = this.getLinkerLinePoints(t); - var v = { - x: q.x - s, - y: q.y - }; - var w = { - x: q.x + s, - y: q.y - }; - var x = { - x: q.x, - y: q.y - s - }; - var m = { - x: q.x, - y: q.y + s - }; - for (var u = 1; u < o.length; u++) { - var n = o[u - 1]; - var p = o[u]; - var r = this.checkCross(v, w, n, p); - if (r) { - return u - } - r = this.checkCross(x, m, n, p); - if (r) { - return u - } - } - return - 1 - }, - getLinkerLength: function(n) { - var d = this.getLinkerLinePoints(n); - var i = 0; - for (var l = 1; l < d.length; l++) { - var j = d[l - 1]; - var m = d[l]; - var k = Utils.measureDistance(j, m); - i += k - } - return i - }, - getShapesByRange: function(j) { - var g = []; - for (var h in Model.define.elements) { - var f = Model.getShapeById(h); - var i = f.props; - if (f.name == "linker") { - i = this.getLinkerBox(f) - } else { - i = this.getShapeBox(f) - } - if (this.pointInRect(i.x, i.y, j) && this.pointInRect(i.x + i.w, i.y, j) && this.pointInRect(i.x + i.w, i.y + i.h, j) && this.pointInRect(i.x, i.y + i.h, j)) { - g.push(f.id) - } - } - return g - }, - getControlBox: function(l) { - var j = { - x1: null, - y1: null, - x2: null, - y2: null - }; - for (var h = 0; h < l.length; h++) { - var k = l[h]; - var i = Model.getShapeById(k); - var m; - if (i.name == "linker") { - m = this.getLinkerBox(i) - } else { - m = this.getShapeBox(i) - } - if (j.x1 == null || m.x < j.x1) { - j.x1 = m.x - } - if (j.y1 == null || m.y < j.y1) { - j.y1 = m.y - } - if (j.x2 == null || m.x + m.w > j.x2) { - j.x2 = m.x + m.w - } - if (j.y2 == null || m.y + m.h > j.y2) { - j.y2 = m.y + m.h - } - } - var n = { - x: j.x1, - y: j.y1, - w: j.x2 - j.x1, - h: j.y2 - j.y1 - }; - return n - }, - getShapesBounding: function(h) { - var i = { - x1: null, - y1: null, - x2: null, - y2: null - }; - for (var l = 0; l < h.length; l++) { - var g = h[l]; - var k; - if (g.name == "linker") { - k = this.getLinkerBox(g) - } else { - k = g.props - } - if (i.x1 == null || k.x < i.x1) { - i.x1 = k.x - } - if (i.y1 == null || k.y < i.y1) { - i.y1 = k.y - } - if (i.x2 == null || k.x + k.w > i.x2) { - i.x2 = k.x + k.w - } - if (i.y2 == null || k.y + k.h > i.y2) { - i.y2 = k.y + k.h - } - } - var j = { - x: i.x1, - y: i.y1, - w: i.x2 - i.x1, - h: i.y2 - i.y1 - }; - return j - }, - getShapeContext: function(c) { - var d = Utils.getDomById(c); - return d.getElementsByTagName("canvas")[0].getContext("2d") - }, - selectIds: [], - selectShape: function(s, w) { - if (typeof s == "string") { - var o = s; - s = []; - s.push(o) - } - if (s.length <= 0) { - return - } - var r = Utils.mergeArray([], s); - for (var u = 0; u < s.length; u++) { - var p = Model.getShapeById(s[u]); - if (p && p.group) { - var x = Model.getGroupShapes(p.group); - Utils.mergeArray(r, x) - } - } - var z = []; - for (var u = 0; u < r.length; u++) { - var y = r[u]; - var p = Model.getShapeById(y); - if (p && p.parent && p.resizeDir.length == 0 && z.indexOf(p.parent) < 0) { - z.push(p.parent) - } else { - if (z.indexOf(y) < 0) { - z.push(y) - } - } - } - s = z; - Utils.removeAnchors(); - Utils.selectIds = []; - for (var q = 0; q < s.length; q++) { - var o = s[q]; - var p = Model.getShapeById(o); - Utils.selectIds.push(o); - if (p && p.name == "linker") { - if (this.isLocked(p.id)) { - Utils.showLockers(p) - } else { - Designer.painter.renderLinker(p) - } - } else { - if (p && this.isLocked(p.id)) { - Utils.showLockers(p) - } else { - //by bzp 处理富文本显示的按钮 - if(p.name == "regulation" && methodId == 'control.policy'){ - parent.$("#dock_btn_richtext").show(); - } - //by bzp end - Utils.showAnchors(p) - } - } - } - var z = Utils.getSelectedIds(); - var i = false; - if (z.length == 1) { - var t = Model.getShapeById(z[0]); - if (t.name == "linker") { - i = true; - Utils.showLinkerControls() - } - } - if (z.length > 0 && !i) { - var v = Designer.painter.drawControls(z) - } - if (typeof w == "undefined") { - w = true - } - if (this.selectCallback && w) { - this.selectCallback() - } - Designer.events.push("selectChanged"); - this.showLinkerCursor() - }, - selectCallback: null, - unselect: function() { - var h = this.selectIds; - this.selectIds = []; - for (var e = 0; e < h.length; e++) { - var g = h[e]; - var f = Model.getShapeById(g); - if (f.name == "linker") { - Designer.painter.renderLinker(f) - } - } - $("#shape_controls").hide(); - Utils.removeLockers(); - Utils.removeAnchors(); - if ($("#dock_content_attribute").is(":visible")) { - $("#tagContent1 :focus").blur() - } - Designer.events.push("selectChanged"); - this.hideLinkerCursor(); - this.hideLinkerControls() - }, - getSelected: function() { - var f = []; - for (var e = 0; e < this.selectIds.length; e++) { - var g = this.selectIds[e]; - if (!Utils.isLocked(g)) { - var h = Model.getShapeById(g); - f.push(h) - } - } - return f - }, - getSelectedIds: function() { - var e = []; - for (var d = 0; d < this.selectIds.length; d++) { - var f = this.selectIds[d]; - if (!Utils.isLocked(f)) { - e.push(f) - } - } - return e - }, - getSelectedLinkers: function() { - var f = []; - for (var e = 0; e < this.selectIds.length; e++) { - var g = this.selectIds[e]; - if (!Utils.isLocked(g)) { - var h = Model.getShapeById(g); - if (h.name == "linker") { - f.push(h) - } - } - } - return f - }, - getSelectedLinkerIds: function() { - var f = []; - for (var e = 0; e < this.selectIds.length; e++) { - var g = this.selectIds[e]; - if (!Utils.isLocked(g)) { - var h = Model.getShapeById(g); - if (h.name == "linker") { - f.push(g) - } - } - } - return f - }, - getSelectedShapeIds: function() { - var f = []; - for (var e = 0; e < this.selectIds.length; e++) { - var g = this.selectIds[e]; - if (!Utils.isLocked(g)) { - var h = Model.getShapeById(g); - if (h.name != "linker") { - f.push(g) - } - } - } - return f - }, - getSelectedLockedIds: function() { - var e = []; - for (var d = 0; d < this.selectIds.length; d++) { - var f = this.selectIds[d]; - if (Utils.isLocked(f)) { - e.push(f) - } - } - return e - }, - getSelectedGroups: function() { - var f = []; - for (var h = 0; h < this.selectIds.length; h++) { - var g = this.selectIds[h]; - var e = Model.getShapeById(g); - if (e.group && f.indexOf(e.group) < 0) { - f.push(e.group) - } - } - return f - }, - isSelected: function(b) { - if (this.selectIds.indexOf(b) >= 0 && !this.isLocked(b)) { - return true - } - return false - }, - isLocked: function(b) { - if (Model.getShapeById(b).locked) { - return true - } else { - return false - } - }, - linkerCursorTimer: null, - showLinkerCursor: function() { - this.hideLinkerCursor(); - var C = Utils.getSelectedIds(); - if (C.length == 1) { - var J = Model.getShapeById(C[0]); - if (J.name != "linker") { - var H = Model.linkerMap.map[J.id]; - if (H && H.length) { - var B = []; - for (var z = 0; z < H.length; z++) { - var d = H[z]; - var E = Model.getShapeById(d); - if (J.id != E.from.id || !E.to.id) { - continue - } - var y = this.getLinkerLength(E).toScale(); - var A = []; - if (E.linkerType == "broken") { - A.push({ - x: E.from.x.toScale(), - y: E.from.y.toScale(), - t: 0 - }); - for (var p = 0; p < E.points.length; p++) { - var D = E.points[p]; - A.push({ - x: D.x.toScale(), - y: D.y.toScale() - }) - } - A.push({ - x: E.to.x.toScale(), - y: E.to.y.toScale() - }); - var w = 0; - for (var p = 1; p < A.length; p++) { - var K = A[p - 1]; - var L = A[p]; - w += Utils.measureDistance(K, L); - L.t = w / y - } - } - var F = Math.floor(y / 120) + 1; - var I = 3 / y; - var i = (Math.ceil(y / 120) * 120) / y; - var x = 0; - while (x < y) { - var G = { - t: x / y, - step: I, - linker: E, - points: A, - maxT: i - }; - B.push(G); - x += 120 - } - } - this.playLinkerCursor(B) - } - } - } - }, - playLinkerCursor: function(l) { - for (var h = 0; h < l.length; h++) { - var j = l[h]; - var k = $("
    ").appendTo("#designer_canvas"); - var m = j.linker; - var i = (m.lineStyle.lineWidth + 2).toScale(); - if (i < 5) { - i = 5 - } - var n = i / 2; - j.half = n; - j.dom = k; - k.css({ - width: i, - height: i, - "-webkit-border-radius": n, - "-moz-border-radius": n, - "-ms-border-radius": n, - "-o-border-radius": n, - "border-radius": n, - "z-index": $("#" + m.id).css("z-index") - }) - } - this.linkerCursorTimer = setInterval(function() { - for (var w = 0; w < l.length; w++) { - var c = l[w]; - var t = c.linker; - if (c.t >= c.maxT) { - c.t = 0; - c.dom.show() - } - var y = c.t; - if (t.linkerType == "broken") { - for (var v = 1; v < c.points.length; v++) { - var b = c.points[v - 1]; - var d = c.points[v]; - if (y >= b.t && y < d.t) { - var x = (y - b.t) / (d.t - b.t); - var f = (1 - x) * b.x + x * d.x; - var g = (1 - x) * b.y + x * d.y; - c.dom.css({ - left: f - c.half, - top: g - c.half - }); - break - } - } - } else { - if (t.linkerType == "curve") { - var a = t.from; - var b = t.points[0]; - var d = t.points[1]; - var e = t.to; - var f = a.x.toScale() * Math.pow((1 - y), 3) + b.x.toScale() * y * Math.pow((1 - y), 2) * 3 + d.x.toScale() * Math.pow(y, 2) * (1 - y) * 3 + e.x.toScale() * Math.pow(y, 3); - var g = a.y.toScale() * Math.pow((1 - y), 3) + b.y.toScale() * y * Math.pow((1 - y), 2) * 3 + d.y.toScale() * Math.pow(y, 2) * (1 - y) * 3 + e.y.toScale() * Math.pow(y, 3); - c.dom.css({ - left: f - c.half, - top: g - c.half - }) - } else { - var f = (1 - y) * t.from.x.toScale() + y * t.to.x.toScale(); - var g = (1 - y) * t.from.y.toScale() + y * t.to.y.toScale(); - c.dom.css({ - left: f - c.half, - top: g - c.half - }) - } - } - c.t += c.step; - if (c.t >= 1) { - c.dom.hide() - } - } - }, - 30) - }, - hideLinkerCursor: function() { - if (this.linkerCursorTimer) { - clearInterval(this.linkerCursorTimer) - } - $(".linker_cursor").remove() - }, - showLinkerControls: function() { - this.hideLinkerControls(); - var e = Utils.getSelectedIds(); - var h = null; - if (e.length == 1) { - var f = Model.getShapeById(e[0]); - if (f.name == "linker" && f.linkerType == "curve") { - h = f - } - } - if (h == null) { - return - } - function g(r, s) { - var t = null; - var b = null; - if (s == "from") { - t = r.from; - b = r.points[0] - } else { - t = r.to; - b = r.points[1] - } - var q = Utils.measureDistance(t, b).toScale() - 6; - var c = { - x: (0.5 * t.x + 0.5 * b.x).toScale(), - y: (0.5 * t.y + 0.5 * b.y).toScale() - }; - var u = Utils.getAngle(t, b) + Math.PI / 2; - var a = $("
    ").appendTo("#designer_canvas"); - var d = $("
    ").appendTo("#designer_canvas"); - var v = Math.round(u / (Math.PI * 2) * 360); - var p = "rotate(" + v + "deg)"; - a.css({ - left: c.x, - top: c.y - q / 2, - height: q, - "z-index": Model.orderList.length, - "-webkit-transform": p, - "-ms-transform": p, - "-o-transform": p, - "-moz-transform": p, - transform: p - }); - d.css({ - left: b.x.toScale() - 4, - top: b.y.toScale() - 4, - "z-index": Model.orderList.length - }); - d.attr("ty", s); - d.unbind().bind("mousedown", - function(j) { - r = Model.getShapeById(r.id); - var i = null; - if (s == "from") { - i = r.points[0] - } else { - i = r.points[1] - } - j.stopPropagation(); - d.addClass("moving"); - Designer.op.changeState("changing_curve"); - $(document).bind("mousemove.change_curve", - function(l) { - var k = Utils.getRelativePos(l.pageX, l.pageY, $("#designer_canvas")); - i.x = k.x; - i.y = k.y; - Designer.painter.renderLinker(r); - Model.define.elements[r.id] = r; - Utils.showLinkerControls(); - $(".linker_control_point[ty=" + d.attr("ty") + "]").addClass("moving"); - $(document).unbind("mouseup.changed_curve").bind("mouseup.changed_curve", - function(m) { - Model.update(r); - $(document).unbind("mouseup.changed_curve") - }) - }); - $(document).unbind("mouseup.change_curve").bind("mouseup.change_curve", - function(k) { - $(document).unbind("mouseup.change_curve"); - $(document).unbind("mousemove.change_curve"); - $(".linker_control_point").removeClass("moving"); - Designer.op.resetState() - }) - }); - return d - } - g(h, "from"); - g(h, "to") - }, - hideLinkerControls: function() { - $(".linker_control_line").remove(); - $(".linker_control_point").remove() - }, - showAnchors: function(n) { - if ($(".shape_contour[forshape=" + n.id + "]").length > 0) { - return - } - var q = $("
    ").appendTo($("#designer_canvas")); - q.css({ - left: n.props.x.toScale(), - top: n.props.y.toScale(), - "z-index": Model.orderList.length + 1 - }); - if (!Utils.isSelected(n.id)) { - q.addClass("hovered_contour") - } - var t = Designer.config.anchorSize - 2; - var u = { - "border-color": Designer.config.anchorColor, - "border-radius": Designer.config.anchorSize / 2, - width: t, - height: t - }; - var v = n.getAnchors(); - var o = { - x: n.props.w / 2, - y: n.props.h / 2 - }; - var r = n.props.angle; - for (var m = 0; m < v.length; m++) { - var p = v[m]; - var l = $("
    ").appendTo(q); - var s = this.getRotated(o, p, r); - u.left = s.x.toScale() - Designer.config.anchorSize / 2; - u.top = s.y.toScale() - Designer.config.anchorSize / 2; - l.css(u) - } - }, - hideAnchors: function() { - $(".hovered_contour").remove() - }, - removeAnchors: function() { - //by bzp - $("#dock_btn_richtext").hide(); - $(".shape_contour").remove() - }, - showLockers: function(s) { - var m = $("#" + s.id); - var q = m.position(); - function t() { - var c = $("").appendTo(m); - var a = c[0].getContext("2d"); - a.strokeStyle = "#777"; - a.lineWidth = 1; - var b = 9; - a.beginPath(); - a.moveTo(2, 2); - a.lineTo(b, b); - a.moveTo(2, b); - a.lineTo(b, 2); - a.stroke(); - return c - } - function r(b) { - var a = t(); - a.css({ - left: b.x.toScale() - q.left - 5, - top: b.y.toScale() - q.top - 5 - }) - } - if (s.name != "linker") { - var u = s.props; - var v = { - x: u.x + u.w / 2, - y: u.y + u.h / 2 - }; - var l = this.getRotated(v, { - x: u.x, - y: u.y - }, - s.props.angle); - r(l); - var n = this.getRotated(v, { - x: u.x + u.w, - y: u.y - }, - s.props.angle); - r(n); - var o = this.getRotated(v, { - x: u.x + u.w, - y: u.y + u.h - }, - s.props.angle); - r(o); - var p = this.getRotated(v, { - x: u.x, - y: u.y + u.h - }, - s.props.angle); - r(p) - } else { - r(s.from); - r(s.to) - } - }, - removeLockers: function() { - $(".shape_locker").remove() - }, - measureDistance: function(g, h) { - var e = h.y - g.y; - var f = h.x - g.x; - return Math.sqrt(Math.pow(e, 2) + Math.pow(f, 2)) - }, - removeFromArray: function(f, d) { - var e = f.indexOf(d); - if (e >= 0) { - f.splice(e, 1) - } - return f - }, - addToArray: function(f, d) { - var e = f.indexOf(d); - if (e < 0) { - f.push(d) - } - return f - }, - mergeArray: function(e, f) { - for (var h = 0; h < f.length; h++) { - var g = f[h]; - if (e.indexOf(g) < 0) { - e.push(g) - } - } - return e - }, - getCirclePoints: function(j, k, n) { - var l = Math.PI / 18; - var o = []; - for (var p = 0; p < 36; p++) { - var i = l * p; - var m = { - x: j - Math.cos(i) * n, - y: k - Math.sin(i) * n, - angle: i - }; - o.push(m) - } - return o - }, - getPointAngle: function(r, i, p, F) { - var x = $("#" + r).position(); - var y = Utils.getShapeContext(r); - i = i.toScale() - x.left; - p = p.toScale() - x.top; - var E = this.getCirclePoints(i, p, F); - var u = E.length; - var G = false; - for (var w = 0; w < u; w++) { - var D = E[w]; - if (y.isPointInPath(D.x, D.y)) { - D.inPath = true; - G = true - } else { - D.inPath = false - } - } - if (G == false) { - return null - } - var C = null; - var z = null; - for (var w = 0; w < u; w++) { - var D = E[w]; - if (!D.inPath) { - if (C == null) { - var A = E[(w - 1 + u) % u]; - if (A.inPath) { - C = D.angle - } - } - if (z == null) { - var v = E[(w + 1 + u) % u]; - if (v.inPath) { - z = D.angle - } - } - if (C != null && z != null) { - break - } - } - } - var H = (Math.PI * 2 + z - C) % (Math.PI * 2) / 2; - var B = (C + H) % (Math.PI * 2); - return B - }, - getAngleDir: function(c) { - var d = Math.PI; - if (c >= d / 4 && c < d / 4 * 3) { - return 1 - } else { - if (c >= d / 4 * 3 && c < d / 4 * 5) { - return 2 - } else { - if (c >= d / 4 * 5 && c < d / 4 * 7) { - return 3 - } else { - return 4 - } - } - } - }, - getLinkerPoints: function(G) { - var O = []; - if (G.linkerType == "broken") { - var J = Math.PI; - var y = G.from; - var aa = G.to; - var R = Math.abs(aa.x - y.x); - var I = Math.abs(aa.y - y.y); - var K = 30; - if (y.id != null && aa.id != null) { - var ab = this.getAngleDir(y.angle); - var ac = this.getAngleDir(aa.angle); - var X, V, S; - if (ab == 1 && ac == 1) { - if (y.y < aa.y) { - X = y; - V = aa; - S = false - } else { - X = aa; - V = y; - S = true - } - var W = Model.getShapeById(X.id).props; - var E = Model.getShapeById(V.id).props; - if (V.x >= W.x - K && V.x <= W.x + W.w + K) { - var P; - if (V.x < W.x + W.w / 2) { - P = W.x - K - } else { - P = W.x + W.w + K - } - var Q = X.y - K; - O.push({ - x: X.x, - y: Q - }); - O.push({ - x: P, - y: Q - }); - Q = V.y - K; - O.push({ - x: P, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } else { - var Q = X.y - K; - O.push({ - x: X.x, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } - } else { - if (ab == 3 && ac == 3) { - if (y.y > aa.y) { - X = y; - V = aa; - S = false - } else { - X = aa; - V = y; - S = true - } - var W = Model.getShapeById(X.id).props; - var E = Model.getShapeById(V.id).props; - if (V.x >= W.x - K && V.x <= W.x + W.w + K) { - var Q = X.y + K; - var P; - if (V.x < W.x + W.w / 2) { - P = W.x - K - } else { - P = W.x + W.w + K - } - O.push({ - x: X.x, - y: Q - }); - O.push({ - x: P, - y: Q - }); - Q = V.y + K; - O.push({ - x: P, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } else { - var Q = X.y + K; - O.push({ - x: X.x, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } - } else { - if (ab == 2 && ac == 2) { - if (y.x > aa.x) { - X = y; - V = aa; - S = false - } else { - X = aa; - V = y; - S = true - } - var W = Model.getShapeById(X.id).props; - var E = Model.getShapeById(V.id).props; - if (V.y >= W.y - K && V.y <= W.y + W.h + K) { - var P = X.x + K; - var Q; - if (V.y < W.y + W.h / 2) { - Q = W.y - K - } else { - Q = W.y + W.h + K - } - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: Q - }); - P = V.x + K; - O.push({ - x: P, - y: Q - }); - O.push({ - x: P, - y: V.y - }) - } else { - var P = X.x + K; - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: V.y - }) - } - } else { - if (ab == 4 && ac == 4) { - if (y.x < aa.x) { - X = y; - V = aa; - S = false - } else { - X = aa; - V = y; - S = true - } - var W = Model.getShapeById(X.id).props; - var E = Model.getShapeById(V.id).props; - if (V.y >= W.y - K && V.y <= W.y + W.h + K) { - var P = X.x - K; - var Q; - if (V.y < W.y + W.h / 2) { - Q = W.y - K - } else { - Q = W.y + W.h + K - } - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: Q - }); - P = V.x - K; - O.push({ - x: P, - y: Q - }); - O.push({ - x: P, - y: V.y - }) - } else { - var P = X.x - K; - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: V.y - }) - } - } else { - if ((ab == 1 && ac == 3) || (ab == 3 && ac == 1)) { - if (ab == 1) { - X = y; - V = aa; - S = false - } else { - X = aa; - V = y; - S = true - } - var W = Model.getShapeById(X.id).props; - var E = Model.getShapeById(V.id).props; - if (V.y <= X.y) { - var Q = X.y - I / 2; - O.push({ - x: X.x, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } else { - var ad = W.x + W.w; - var U = E.x + E.w; - var Q = X.y - K; - var P; - if (U >= W.x && E.x <= ad) { - var x = W.x + W.w / 2; - if (V.x < x) { - P = W.x < E.x ? W.x - K: E.x - K - } else { - P = ad > U ? ad + K: U + K - } - if (E.y < X.y) { - Q = E.y - K - } - } else { - if (V.x < X.x) { - P = U + (W.x - U) / 2 - } else { - P = ad + (E.x - ad) / 2 - } - } - O.push({ - x: X.x, - y: Q - }); - O.push({ - x: P, - y: Q - }); - Q = V.y + K; - O.push({ - x: P, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } - } else { - if ((ab == 2 && ac == 4) || (ab == 4 && ac == 2)) { - if (ab == 2) { - X = y; - V = aa; - S = false - } else { - X = aa; - V = y; - S = true - } - var W = Model.getShapeById(X.id).props; - var E = Model.getShapeById(V.id).props; - if (V.x > X.x) { - var P = X.x + R / 2; - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: V.y - }) - } else { - var F = W.y + W.h; - var N = E.y + E.h; - var P = X.x + K; - var Q; - if (N >= W.y && E.y <= F) { - var x = W.y + W.h / 2; - if (V.y < x) { - Q = W.y < E.y ? W.y - K: E.y - K - } else { - Q = F > N ? F + K: N + K - } - if (E.x + E.w > X.x) { - P = E.x + E.w + K - } - } else { - if (V.y < X.y) { - Q = N + (W.y - N) / 2 - } else { - Q = F + (E.y - F) / 2 - } - } - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: Q - }); - P = V.x - K; - O.push({ - x: P, - y: Q - }); - O.push({ - x: P, - y: V.y - }) - } - } else { - if ((ab == 1 && ac == 2) || (ab == 2 && ac == 1)) { - if (ab == 2) { - X = y; - V = aa; - S = false - } else { - X = aa; - V = y; - S = true - } - var W = Model.getShapeById(X.id).props; - var E = Model.getShapeById(V.id).props; - if (V.x > X.x && V.y > X.y) { - O.push({ - x: V.x, - y: X.y - }) - } else { - if (V.x > X.x && E.x > X.x) { - var P; - if (E.x - X.x < K * 2) { - P = X.x + (E.x - X.x) / 2 - } else { - P = X.x + K - } - var Q = V.y - K; - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } else { - if (V.x <= X.x && V.y > W.y + W.h) { - var F = W.y + W.h; - var P = X.x + K; - var Q; - if (V.y - F < K * 2) { - Q = F + (V.y - F) / 2 - } else { - Q = V.y - K - } - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } else { - var P; - var U = E.x + E.w; - if (U > X.x) { - P = U + K - } else { - P = X.x + K - } - var Q; - if (V.y < W.y) { - Q = V.y - K - } else { - Q = W.y - K - } - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } - } - } - } else { - if ((ab == 1 && ac == 4) || (ab == 4 && ac == 1)) { - if (ab == 4) { - X = y; - V = aa; - S = false - } else { - X = aa; - V = y; - S = true - } - var W = Model.getShapeById(X.id).props; - var E = Model.getShapeById(V.id).props; - var U = E.x + E.w; - if (V.x < X.x && V.y > X.y) { - O.push({ - x: V.x, - y: X.y - }) - } else { - if (V.x < X.x && U < X.x) { - var P; - if (X.x - U < K * 2) { - P = U + (X.x - U) / 2 - } else { - P = X.x - K - } - var Q = V.y - K; - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } else { - if (V.x >= X.x && V.y > W.y + W.h) { - var F = W.y + W.h; - var P = X.x - K; - var Q; - if (V.y - F < K * 2) { - Q = F + (V.y - F) / 2 - } else { - Q = V.y - K - } - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } else { - var P; - if (E.x < X.x) { - P = E.x - K - } else { - P = X.x - K - } - var Q; - if (V.y < W.y) { - Q = V.y - K - } else { - Q = W.y - K - } - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } - } - } - } else { - if ((ab == 2 && ac == 3) || (ab == 3 && ac == 2)) { - if (ab == 2) { - X = y; - V = aa; - S = false - } else { - X = aa; - V = y; - S = true - } - var W = Model.getShapeById(X.id).props; - var E = Model.getShapeById(V.id).props; - if (V.x > X.x && V.y < X.y) { - O.push({ - x: V.x, - y: X.y - }) - } else { - if (V.x > X.x && E.x > X.x) { - var P; - if (E.x - X.x < K * 2) { - P = X.x + (E.x - X.x) / 2 - } else { - P = X.x + K - } - var Q = V.y + K; - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } else { - if (V.x <= X.x && V.y < W.y) { - var P = X.x + K; - var Q; - if (W.y - V.y < K * 2) { - Q = V.y + (W.y - V.y) / 2 - } else { - Q = V.y + K - } - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } else { - var P; - var U = E.x + E.w; - if (U > X.x) { - P = U + K - } else { - P = X.x + K - } - var Q; - if (V.y > W.y + W.h) { - Q = V.y + K - } else { - Q = W.y + W.h + K - } - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } - } - } - } else { - if ((ab == 3 && ac == 4) || (ab == 4 && ac == 3)) { - if (ab == 4) { - X = y; - V = aa; - S = false - } else { - X = aa; - V = y; - S = true - } - var W = Model.getShapeById(X.id).props; - var E = Model.getShapeById(V.id).props; - var U = E.x + E.w; - if (V.x < X.x && V.y < X.y) { - O.push({ - x: V.x, - y: X.y - }) - } else { - if (V.x < X.x && U < X.x) { - var P; - if (X.x - U < K * 2) { - P = U + (X.x - U) / 2 - } else { - P = X.x - K - } - var Q = V.y + K; - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } else { - if (V.x >= X.x && V.y < W.y) { - var P = X.x - K; - var Q; - if (W.y - V.y < K * 2) { - Q = V.y + (W.y - V.y) / 2 - } else { - Q = V.y + K - } - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } else { - var P; - if (E.x < X.x) { - P = E.x - K - } else { - P = X.x - K - } - var Q; - if (V.y > W.y + W.h) { - Q = V.y + K - } else { - Q = W.y + W.h + K - } - O.push({ - x: P, - y: X.y - }); - O.push({ - x: P, - y: Q - }); - O.push({ - x: V.x, - y: Q - }) - } - } - } - } - } - } - } - } - } - } - } - } - } - if (S) { - O.reverse() - } - } else { - if (y.id != null || aa.id != null) { - var X, V, S, M; - if (y.id != null) { - X = y; - V = aa; - S = false; - M = y.angle - } else { - X = aa; - V = y; - S = true; - M = aa.angle - } - var Z = Model.getShapeById(X.id).props; - if (M >= J / 4 && M < J / 4 * 3) { - if (V.y < X.y) { - if (R >= I) { - O.push({ - x: X.x, - y: V.y - }) - } else { - var x = I / 2; - O.push({ - x: X.x, - y: X.y - x - }); - O.push({ - x: V.x, - y: X.y - x - }) - } - } else { - O.push({ - x: X.x, - y: X.y - K - }); - if (R >= I) { - if (V.x >= Z.x - K && V.x <= Z.x + Z.w + K) { - var L = Z.x + Z.w / 2; - if (V.x < L) { - O.push({ - x: Z.x - K, - y: X.y - K - }); - O.push({ - x: Z.x - K, - y: V.y - }) - } else { - O.push({ - x: Z.x + Z.w + K, - y: X.y - K - }); - O.push({ - x: Z.x + Z.w + K, - y: V.y - }) - } - } else { - if (V.x < Z.x) { - O.push({ - x: V.x + K, - y: X.y - K - }); - O.push({ - x: V.x + K, - y: V.y - }) - } else { - O.push({ - x: V.x - K, - y: X.y - K - }); - O.push({ - x: V.x - K, - y: V.y - }) - } - } - } else { - if (V.x >= Z.x - K && V.x <= Z.x + Z.w + K) { - var L = Z.x + Z.w / 2; - if (V.x < L) { - O.push({ - x: Z.x - K, - y: X.y - K - }); - O.push({ - x: Z.x - K, - y: V.y - K - }); - O.push({ - x: V.x, - y: V.y - K - }) - } else { - O.push({ - x: Z.x + Z.w + K, - y: X.y - K - }); - O.push({ - x: Z.x + Z.w + K, - y: V.y - K - }); - O.push({ - x: V.x, - y: V.y - K - }) - } - } else { - O.push({ - x: V.x, - y: X.y - K - }) - } - } - } - } else { - if (M >= J / 4 * 3 && M < J / 4 * 5) { - if (V.x > X.x) { - if (R >= I) { - var x = R / 2; - O.push({ - x: X.x + x, - y: X.y - }); - O.push({ - x: X.x + x, - y: V.y - }) - } else { - O.push({ - x: V.x, - y: X.y - }) - } - } else { - O.push({ - x: X.x + K, - y: X.y - }); - if (R >= I) { - if (V.y >= Z.y - K && V.y <= Z.y + Z.h + K) { - var L = Z.y + Z.h / 2; - if (V.y < L) { - O.push({ - x: X.x + K, - y: Z.y - K - }); - O.push({ - x: V.x + K, - y: Z.y - K - }); - O.push({ - x: V.x + K, - y: V.y - }) - } else { - O.push({ - x: X.x + K, - y: Z.y + Z.h + K - }); - O.push({ - x: V.x + K, - y: Z.y + Z.h + K - }); - O.push({ - x: V.x + K, - y: V.y - }) - } - } else { - O.push({ - x: X.x + K, - y: V.y - }) - } - } else { - if (V.y >= Z.y - K && V.y <= Z.y + Z.h + K) { - var L = Z.y + Z.h / 2; - if (V.y < L) { - O.push({ - x: X.x + K, - y: Z.y - K - }); - O.push({ - x: V.x, - y: Z.y - K - }) - } else { - O.push({ - x: X.x + K, - y: Z.y + Z.h + K - }); - O.push({ - x: V.x, - y: Z.y + Z.h + K - }) - } - } else { - if (V.y < X.y) { - O.push({ - x: X.x + K, - y: V.y + K - }); - O.push({ - x: V.x, - y: V.y + K - }) - } else { - O.push({ - x: X.x + K, - y: V.y - K - }); - O.push({ - x: V.x, - y: V.y - K - }) - } - } - } - } - } else { - if (M >= J / 4 * 5 && M < J / 4 * 7) { - if (V.y > X.y) { - if (R >= I) { - O.push({ - x: X.x, - y: V.y - }) - } else { - var x = I / 2; - O.push({ - x: X.x, - y: X.y + x - }); - O.push({ - x: V.x, - y: X.y + x - }) - } - } else { - O.push({ - x: X.x, - y: X.y + K - }); - if (R >= I) { - if (V.x >= Z.x - K && V.x <= Z.x + Z.w + K) { - var L = Z.x + Z.w / 2; - if (V.x < L) { - O.push({ - x: Z.x - K, - y: X.y + K - }); - O.push({ - x: Z.x - K, - y: V.y - }) - } else { - O.push({ - x: Z.x + Z.w + K, - y: X.y + K - }); - O.push({ - x: Z.x + Z.w + K, - y: V.y - }) - } - } else { - if (V.x < Z.x) { - O.push({ - x: V.x + K, - y: X.y + K - }); - O.push({ - x: V.x + K, - y: V.y - }) - } else { - O.push({ - x: V.x - K, - y: X.y + K - }); - O.push({ - x: V.x - K, - y: V.y - }) - } - } - } else { - if (V.x >= Z.x - K && V.x <= Z.x + Z.w + K) { - var L = Z.x + Z.w / 2; - if (V.x < L) { - O.push({ - x: Z.x - K, - y: X.y + K - }); - O.push({ - x: Z.x - K, - y: V.y + K - }); - O.push({ - x: V.x, - y: V.y + K - }) - } else { - O.push({ - x: Z.x + Z.w + K, - y: X.y + K - }); - O.push({ - x: Z.x + Z.w + K, - y: V.y + K - }); - O.push({ - x: V.x, - y: V.y + K - }) - } - } else { - O.push({ - x: V.x, - y: X.y + K - }) - } - } - } - } else { - if (V.x < X.x) { - if (R >= I) { - var x = R / 2; - O.push({ - x: X.x - x, - y: X.y - }); - O.push({ - x: X.x - x, - y: V.y - }) - } else { - O.push({ - x: V.x, - y: X.y - }) - } - } else { - O.push({ - x: X.x - K, - y: X.y - }); - if (R >= I) { - if (V.y >= Z.y - K && V.y <= Z.y + Z.h + K) { - var L = Z.y + Z.h / 2; - if (V.y < L) { - O.push({ - x: X.x - K, - y: Z.y - K - }); - O.push({ - x: V.x - K, - y: Z.y - K - }); - O.push({ - x: V.x - K, - y: V.y - }) - } else { - O.push({ - x: X.x - K, - y: Z.y + Z.h + K - }); - O.push({ - x: V.x - K, - y: Z.y + Z.h + K - }); - O.push({ - x: V.x - K, - y: V.y - }) - } - } else { - O.push({ - x: X.x - K, - y: V.y - }) - } - } else { - if (V.y >= Z.y - K && V.y <= Z.y + Z.h + K) { - var L = Z.y + Z.h / 2; - if (V.y < L) { - O.push({ - x: X.x - K, - y: Z.y - K - }); - O.push({ - x: V.x, - y: Z.y - K - }) - } else { - O.push({ - x: X.x - K, - y: Z.y + Z.h + K - }); - O.push({ - x: V.x, - y: Z.y + Z.h + K - }) - } - } else { - if (V.y < X.y) { - O.push({ - x: X.x - K, - y: V.y + K - }); - O.push({ - x: V.x, - y: V.y + K - }) - } else { - O.push({ - x: X.x - K, - y: V.y - K - }); - O.push({ - x: V.x, - y: V.y - K - }) - } - } - } - } - } - } - } - if (S) { - O.reverse() - } - } else { - if (R >= I) { - var x = (aa.x - y.x) / 2; - O.push({ - x: y.x + x, - y: y.y - }); - O.push({ - x: y.x + x, - y: aa.y - }) - } else { - var x = (aa.y - y.y) / 2; - O.push({ - x: y.x, - y: y.y + x - }); - O.push({ - x: aa.x, - y: y.y + x - }) - } - } - } - } else { - if (G.linkerType == "curve") { - var y = G.from; - var aa = G.to; - var Y = this.measureDistance(y, aa); - var T = Y * 0.4; - function H(e, d) { - if (e.id != null) { - return { - x: e.x - T * Math.cos(e.angle), - y: e.y - T * Math.sin(e.angle) - } - } else { - var c = Math.abs(e.y - d.y); - var f = Math.abs(e.x - d.x); - var b = Math.atan(c / f); - var a = {}; - if (e.x <= d.x) { - a.x = e.x + T * Math.cos(b) - } else { - a.x = e.x - T * Math.cos(b) - } - if (e.y <= d.y) { - a.y = e.y + T * Math.sin(b) - } else { - a.y = e.y - T * Math.sin(b) - } - return a - } - } - O.push(H(y, aa)); - O.push(H(aa, y)) - } - } - return O - }, - getLinkerLinePoints: function(i) { - var f = []; - if (i.linkerType != "curve") { - f.push(i.from); - f = f.concat(i.points) - } else { - var j = 0.05; - var g = 0; - while (g <= 1) { - var h = { - x: (1 - g) * (1 - g) * (1 - g) * i.from.x + 3 * (1 - g) * (1 - g) * g * i.points[0].x + 3 * (1 - g) * g * g * i.points[1].x + g * g * g * i.to.x, - y: (1 - g) * (1 - g) * (1 - g) * i.from.y + 3 * (1 - g) * (1 - g) * g * i.points[0].y + 3 * (1 - g) * g * g * i.points[1].y + g * g * g * i.to.y - }; - f.push(h); - g += j - } - } - f.push(i.to); - return f - }, - getLinkerBox: function(l) { - var i = this.getLinkerLinePoints(l); - var o = i[0].x; - var p = i[0].y; - var q = i[0].x; - var r = i[0].y; - for (var n = 0; n < i.length; n++) { - var k = i[n]; - if (k.x < o) { - o = k.x - } else { - if (k.x > q) { - q = k.x - } - } - if (k.y < p) { - p = k.y - } else { - if (k.y > r) { - r = k.y - } - } - } - var m = { - x: o, - y: p, - w: q - o, - h: r - p - }; - return m - }, - getShapeBox: function(e) { - var d = e.props; - var f = e.props.angle; - return this.getRotatedBox(d, f) - }, - getRotatedBox: function(p, r, u) { - if (r == 0) { - return p - } else { - if (!u) { - u = { - x: p.x + p.w / 2, - y: p.y + p.h / 2 - } - } - var l = this.getRotated(u, { - x: p.x, - y: p.y - }, - r); - var m = this.getRotated(u, { - x: p.x + p.w, - y: p.y - }, - r); - var n = this.getRotated(u, { - x: p.x + p.w, - y: p.y + p.h - }, - r); - var o = this.getRotated(u, { - x: p.x, - y: p.y + p.h - }, - r); - var q = Math.min(l.x, m.x, n.x, o.x); - var t = Math.max(l.x, m.x, n.x, o.x); - var s = Math.min(l.y, m.y, n.y, o.y); - var v = Math.max(l.y, m.y, n.y, o.y); - return { - x: q, - y: s, - w: t - q, - h: v - s - } - } - }, - getRotated: function(n, h, j) { - var k = this.measureDistance(n, h); - if (k == 0 || j == 0) { - return h - } - var m = Math.atan(Math.abs(h.x - n.x) / Math.abs(n.y - h.y)); - if (h.x >= n.x && h.y >= n.y) { - m = Math.PI - m - } else { - if (h.x <= n.x && h.y >= n.y) { - m = Math.PI + m - } else { - if (h.x <= n.x && h.y <= n.y) { - m = Math.PI * 2 - m - } - } - } - m = m % (Math.PI * 2); - var l = (m + j) % (Math.PI * 2); - var i = { - x: n.x + Math.sin(l) * k, - y: n.y - Math.cos(l) * k - }; - return i - }, - getShapeAnchorInLinker: function(H) { - var A = H.getAnchors(); - var G = []; - var t = { - x: H.props.x + H.props.w / 2, - y: H.props.y + H.props.h / 2 - }; - for (var v = 0; v < A.length; v++) { - var y = A[v]; - var x = { - x: y.x + H.props.x, - y: y.y + H.props.y - }; - var E = this.getRotated(t, x, H.props.angle); - G.push(E) - } - var C = []; - var F = 2; - for (var w = Model.orderList.length - 1; w >= 0; w--) { - var z = Model.orderList[w].id; - var i = Model.getShapeById(z); - if (i.name != "linker") { - continue - } - var B = i; - var u = null; - F = 3; - for (var v = 0; v < G.length; v++) { - var J = G[v]; - var I = { - x: J.x - F, - y: J.y - F, - w: F * 2, - h: F * 2 - }; - if (B.from.id == null && this.pointInRect(B.from.x, B.from.y, I)) { - u = { - linker: B, - anchors: [J], - type: "from" - }; - break - } - if (B.to.id == null && this.pointInRect(B.to.x, B.to.y, I)) { - u = { - linker: B, - anchors: [J], - type: "to" - }; - break - } - } - F = 2; - if (u == null) { - for (var v = 0; v < G.length; v++) { - var J = G[v]; - var D = Utils.pointInLinker(J, B, F); - if (D > -1) { - if (u == null) { - u = { - linker: B, - anchors: [], - type: "line" - } - } - u.anchors.push(J) - } - } - } - if (u != null) { - C.push(u) - } - } - return C - }, - getEndpointAngle: function(m, k) { - var i; - if (k == "from") { - i = m.from - } else { - i = m.to - } - var n; - if (m.linkerType == "normal") { - if (k == "from") { - n = m.to - } else { - n = m.from - } - } else { - if (m.linkerType == "broken") { - if (k == "from") { - n = m.points[0] - } else { - n = m.points[m.points.length - 1] - } - } else { - var l = 12; - var h; - var j = Utils.measureDistance(m.from, m.to); - if (k == "from") { - h = l / j - } else { - h = 1 - l / j - } - n = { - x: (1 - h) * (1 - h) * (1 - h) * m.from.x + 3 * (1 - h) * (1 - h) * h * m.points[0].x + 3 * (1 - h) * h * h * m.points[1].x + h * h * h * m.to.x, - y: (1 - h) * (1 - h) * (1 - h) * m.from.y + 3 * (1 - h) * (1 - h) * h * m.points[0].y + 3 * (1 - h) * h * h * m.points[1].y + h * h * h * m.to.y - } - } - } - return this.getAngle(n, i) - }, - getAngle: function(f, e) { - var d = Math.atan(Math.abs(f.y - e.y) / Math.abs(f.x - e.x)); - if (e.x <= f.x && e.y > f.y) { - d = Math.PI - d - } else { - if (e.x < f.x && e.y <= f.y) { - d = Math.PI + d - } else { - if (e.x >= f.x && e.y < f.y) { - d = Math.PI * 2 - d - } - } - } - return d - }, - getDarkerColor: function(q, m) { - if (!m) { - m = 13 - } - var n = q.split(","); - var r = parseInt(n[0]); - var o = parseInt(n[1]); - var l = parseInt(n[2]); - var p = Math.round(r - r / 255 * m); - if (p < 0) { - p = 0 - } - var g = Math.round(o - o / 255 * m); - if (g < 0) { - g = 0 - } - var b = Math.round(l - l / 255 * m); - if (b < 0) { - b = 0 - } - return p + "," + g + "," + b - }, - getDarkestColor: function(b) { - return this.getDarkerColor(b, 26) - }, - toScale: function(f) { - var e = {}; - for (var d in f) { - e[d] = f[d]; - if (typeof f[d] == "number") { - e[d] = e[d].toScale() - } - } - return e - }, - restoreScale: function(f) { - var e = {}; - for (var d in f) { - e[d] = f[d]; - if (typeof f[d] == "number") { - e[d] = e[d].restoreScale() - } - } - return e - }, - getOutlinkers: function(i) { - var l = []; - var j = []; - for (var n = 0; n < i.length; n++) { - var p = i[n]; - if (p != undefined && p.name != "linker") { - var m = Model.getShapeLinkers(p.id); - if (m && m.length > 0) { - for (var o = 0; o < m.length; o++) { - var k = m[o]; - if (!this.isSelected(k) && j.indexOf(k) < 0) { - l.push(Model.getShapeById(k)); - j.push(k) - } - } - } - } - } - return l - }, - getFamilyShapes: function(i) { - var j = []; - for (var m = 0; m < i.length; m++) { - var h = i[m]; - if (h.name != "linker") { - if (h.parent) { - var k = Model.getShapeById(h.parent); - if (!Utils.isSelected(h.parent)) { - j.push(k) - } - var l = this.getChildrenShapes(k); - j = j.concat(l) - } - var n = this.getChildrenShapes(h); - j = j.concat(n) - } - } - return j - }, - getChildrenShapes: function(f) { - var h = []; - if (f.children && f.children.length > 0) { - for (var e = 0; e < f.children.length; e++) { - var g = f.children[e]; - if (!Utils.isSelected(g)) { - h.push(Model.getShapeById(g)) - } - } - } - return h - }, - isFamilyShape: function(c, d) { - if (c.parent == d.id) { - return true - } else { - if (c.id == d.parent) { - return true - } else { - if (c.parent && c.parent == d.parent) { - return true - } - } - } - return false - }, - getContainedShapes: function(n) { - var h = []; - var l = []; - for (var k = 0; k < n.length; k++) { - var m = n[k]; - if (m.name != "linker" && m.attribute && m.attribute.container) { - var j = i(m); - h = h.concat(j) - } - } - function i(e) { - var b = []; - for (var c = Model.orderList.length - 1; c >= 0; c--) { - var f = Model.orderList[c].id; - if (e.id != f && !Utils.isSelected(f) && l.indexOf(f) < 0) { - var d = Model.getShapeById(f); - if (!d.attribute || typeof d.attribute.container == "undefined" || d.attribute.container == false) { - if (!Utils.isFamilyShape(d, e)) { - var a = Utils.getShapeBox(d); - if (Utils.rectInRect(a, e.props)) { - b.push(d); - l.push(f) - } - } - } - } - } - return b - } - return h - }, - getAttachedShapes: function(p) { - var r = []; - for (var m = 0; m < p.length; m++) { - if (p[m] != undefined) { - r.push(p[m].id) - } - } - var l = []; - for (var m = 0; m < p.length; m++) { - var j = p[m]; - if (j != undefined && (j.groupName == "task" || j.groupName == "callActivity" || j.groupName == "subProcess")) { - var q = []; - for (var o = Model.orderList.length - 1; o >= 0; o--) { - var i = Model.orderList[o].id; - var n = Model.getShapeById(i); - if (n.attachTo == j.id && !Utils.isSelected(i) && r.indexOf(i) < 0) { - q.push(n) - } - } - l = l.concat(q) - } - } - return l - }, - copy: function(b) { - return $.extend(true, {}, - b) - }, - rangeChildren: function(s) { - var v = []; - if (s.children && s.children.length > 0) { - if (s.name == "verticalPool") { - var h = []; - var y = []; - for (var u = 0; u < s.children.length; u++) { - var w = s.children[u]; - var x = Model.getShapeById(w); - if (x.name == "horizontalSeparator") { - y.push(x) - } else { - h.push(x) - } - } - h.sort(function(a, b) { - return a.props.x - b.props.x - }); - var q = s.props.x; - for (var u = 0; u < h.length; u++) { - var x = h[u]; - if (x.name == 'verticalLane' && x.props.x != q) { - var m = Utils.getContainedShapes([x]); - var p = Utils.getOutlinkers(m); - m = m.concat(p); - Designer.op.moveShape(m, { - x : (q-x.props.x) * Designer.config.scale, - y : 0 - }); - var linkers = []; - for (var i = 0; i < v.length; i++) { - if (v[i].name == 'linker') { - linkers.push(v[i].id); - } - } - for (var i = 0; i < m.length; i++) { - if (linkers.indexOf(m[i].id) > -1) { - continue; - } - v.push(m[i]); - } - } - x.props.x = q; - Designer.painter.renderShape(x); - v.push(x); - q += x.props.w; - } - y.sort(function(a, b) { - return a.props.y - b.props.y - }); - var r = s.props.y + 40; - for (var u = 0; u < y.length; u++) { - var x = y[u]; - var z = x.props.y + x.props.h; - x.props.w = s.props.w; - x.props.y = r; - var t = z - r; - x.props.h = t; - Designer.painter.renderShape(x); - v.push(x); - r += t - } - } else { - if (s.name == "horizontalPool") { - var h = []; - var y = []; - for (var u = 0; u < s.children.length; u++) { - var w = s.children[u]; - var x = Model.getShapeById(w); - if (x.name == "verticalSeparator") { - y.push(x) - } else { - h.push(x) - } - } - h.sort(function(a, b) { - return a.props.y - b.props.y - }); - var r = s.props.y; - for (var u = 0; u < h.length; u++) { - var x = h[u]; - if (x.name == 'horizontalLane' && x.props.y != r) { - var m = Utils.getContainedShapes([x]); - var p = Utils.getOutlinkers(m); - m = m.concat(p); - Designer.op.moveShape(m, { - x : 0, - y : (r-x.props.y) * Designer.config.scale - }); - var linkers = []; - for (var i = 0; i < v.length; i++) { - if (v[i].name == 'linker') { - linkers.push(v[i].id); - } - } - for (var i = 0; i < m.length; i++) { - if (linkers.indexOf(m[i].id) > -1) { - continue; - } - v.push(m[i]); - } - } - x.props.y = r; - Designer.painter.renderShape(x); - v.push(x); - r += x.props.h - } - y.sort(function(a, b) { - return a.props.x - b.props.x - }); - var q = s.props.x + 40; - for (var u = 0; u < y.length; u++) { - var x = y[u]; - var i = x.props.x + x.props.w; - x.props.h = s.props.h; - x.props.x = q; - var p = i - q; - x.props.w = p; - Designer.painter.renderShape(x); - v.push(x); - q += p - } - } - } - } - return v - }, - getRelativePos: function(h, e, g) { - var f = g.offset(); - if (f == null) { - f = { - left: 0, - top: 0 - } - } - return { - x: h - f.left + g.scrollLeft(), - y: e - f.top + g.scrollTop() - } - }, - getCollapsedShapes: function(b) { - var k = []; - var a = []; - for (var e = 0; e < b.length; e++) { - var f = b[e]; - if (f.attribute && f.attribute.collapsed) { - var h = []; - for (var c = Model.orderList.length - 1; c >= 0; c--) { - var g = Model.orderList[c].id; - var d = Model.getShapeById(g); - if (d.attribute && d.attribute.collapseBy == f.id && a.indexOf(g) < 0) { - h.push(d) - } - } - k = k.concat(h) - } - } - return k - }, - getCollapsedShapesById: function(e) { - var a = []; - for (var c = Model.orderList.length - 1; c >= 0; c--) { - var d = Model.orderList[c].id; - var b = Model.getShapeById(d); - if (b.attribute && b.attribute.collapseBy == e) { - a.push(b) - } - } - return a - }, - getShapeLineStyle: function(a, b) { - if (b == false || !Model.define.theme || !Model.define.theme.shape) { - return $.extend({}, Schema.shapeDefaults.lineStyle, a) - } else { - return $.extend({}, Schema.shapeDefaults.lineStyle, Model.define.theme.shape.lineStyle, a) - } - }, - getLinkerLineStyle: function(a, b) { - if (b == false || !Model.define.theme || !Model.define.theme.linker) { - return $.extend({}, Schema.linkerDefaults.lineStyle, a) - } else { - return $.extend({}, Schema.linkerDefaults.lineStyle, Model.define.theme.linker.lineStyle, a) - } - }, - getShapeFontStyle: function(b, a) { - if (a == false || !Model.define.theme || !Model.define.theme.shape) { - return $.extend({}, Schema.shapeDefaults.fontStyle, b) - } else { - return $.extend({}, Schema.shapeDefaults.fontStyle, Model.define.theme.shape.fontStyle, b) - } - }, - getLinkerFontStyle: function(b, a) { - if (a == false || !Model.define.theme || !Model.define.theme.linker) { - return $.extend({}, Schema.linkerDefaults.fontStyle, b) - } else { - return $.extend({}, Schema.linkerDefaults.fontStyle, Model.define.theme.linker.fontStyle, b) - } - }, - getShapeFillStyle: function(a, b) { - if (b == false || !Model.define.theme || !Model.define.theme.shape) { - return $.extend({}, Schema.shapeDefaults.fillStyle, a) - } else { - return $.extend({}, Schema.shapeDefaults.fillStyle, Model.define.theme.shape.fillStyle, a) - } - }, - containsChinese: function(a) { - if (escape(a).indexOf("%u") >= 0) { - return true - } else { - return false - } - }, - filterXss: function(a) { - a = a.toString(); - a = a.replace(//g, ">"); - a = a.replace(/%3E/g, ">"); - a = a.replace(/'/g, "'"); - a = a.replace(/"/g, """); - return a - } -}; -var GradientHelper = { - createLinearGradient: function(m, j, k) { - var q = m.props; - var p; - var n; - var o; - if (q.w > q.h) { - p = { - x: 0, - y: q.h / 2 - }; - n = { - x: q.w, - y: q.h / 2 - }; - o = (k.angle + Math.PI / 2) % (Math.PI * 2) - } else { - p = { - x: q.w / 2, - y: 0 - }; - n = { - x: q.w / 2, - y: q.h - }; - o = k.angle - } - if (o != 0) { - var r = { - x: q.w / 2, - y: q.h / 2 - }; - p = Utils.getRotated(r, p, o); - n = Utils.getRotated(r, n, o); - if (p.x < 0) { - p.x = 0 - } - if (p.x > m.props.w) { - p.x = m.props.w - } - if (p.y < 0) { - p.y = 0 - } - if (p.y > m.props.h) { - p.y = m.props.h - } - if (n.x < 0) { - n.x = 0 - } - if (n.x > m.props.w) { - n.x = m.props.w - } - if (n.y < 0) { - n.y = 0 - } - if (n.y > m.props.h) { - n.y = m.props.h - } - } - var l = j.createLinearGradient(p.x, p.y, n.x, n.y); - l.addColorStop(0, "rgb(" + k.beginColor + ")"); - l.addColorStop(1, "rgb(" + k.endColor + ")"); - return l - }, - createRadialGradient: function(l, h, g) { - var i = l.props; - var k = i.h; - if (i.w < i.h) { - k = i.w - } - var j = h.createRadialGradient(i.w / 2, i.h / 2, 10, i.w / 2, i.h / 2, k * g.radius); - j.addColorStop(0, "rgb(" + g.beginColor + ")"); - j.addColorStop(1, "rgb(" + g.endColor + ")"); - return j - }, - getLighterColor: function(q) { - var m = 60; - var n = q.split(","); - var r = parseInt(n[0]); - var o = parseInt(n[1]); - var l = parseInt(n[2]); - var p = Math.round(r + (255 - r) / 255 * m); - if (p > 255) { - p = 255 - } - var g = Math.round(o + (255 - o) / 255 * m); - if (g > 255) { - g = 255 - } - var b = Math.round(l + (255 - l) / 255 * m); - if (b > 255) { - b = 255 - } - return p + "," + g + "," + b - }, - getDarkerColor: function(q) { - var m = 60; - var n = q.split(","); - var r = parseInt(n[0]); - var o = parseInt(n[1]); - var l = parseInt(n[2]); - var p = Math.round(r - r / 255 * m); - if (p < 0) { - p = 0 - } - var g = Math.round(o - o / 255 * m); - if (g < 0) { - g = 0 - } - var b = Math.round(l - l / 255 * m); - if (b < 0) { - b = 0 - } - return p + "," + g + "," + b - } -}; -var MessageSource = { - batchSize: 0, - messages: [], - withUndo: true, - withMessage: true, - withDock: true, - undoStack: { - stack: [], - push: function(c, d) { - this.stack.push(c); - if (typeof d == "undefined") { - d = true - } - if (d) { - MessageSource.redoStack.stack = [] - } - Designer.events.push("undoStackChanged", this.stack.length) - }, - pop: function() { - var c = this.stack.length; - if (c == 0) { - return null - } - var d = this.stack[c - 1]; - this.stack.splice(c - 1, 1); - MessageSource.redoStack.push(d); - Designer.events.push("undoStackChanged", this.stack.length); - return d - } - }, - redoStack: { - stack: [], - push: function(b) { - this.stack.push(b); - Designer.events.push("redoStackChanged", this.stack.length) - }, - pop: function() { - var c = this.stack.length; - if (c == 0) { - return null - } - var d = this.stack[c - 1]; - this.stack.splice(c - 1, 1); - MessageSource.undoStack.push(d, false); - Designer.events.push("redoStackChanged", this.stack.length); - return d - } - }, - beginBatch: function() { - this.batchSize++ - }, - commit: function() { - this.batchSize--; - this.submit() - }, - submit: function() { - if (this.batchSize == 0 && this.messages.length != 0) { - if (this.withDock) { - Dock.update(true) - } - if (this.withMessage == false) { - this.messages = []; - return - } - if (this.withUndo) { - this.undoStack.push(this.messages) - } - if (chartId != "") { - var c = JSON.stringify(this.messages); - if (role != "trial") { - $("#saving_tip").text("<@i18n resource='diagraming.saving'/>") - } - var d = { - action: "command", - messages: c, - ignore: "messages", - name: userName - }; - CLB.send(d, - function() { - if (role != "trial") { - $("#saving_tip").text("<@i18n resource='diagraming.saved'/>") - } - }) - } - this.messages = [] - } - }, - send: function(c, d) { - - this.messages.push({ - action: c, - content: d - }); - this.submit() - }, - receive: function(b) { - this.doWithoutMessage(function() { - MessageSource.executeMessages(b, true); - Utils.showLinkerControls(); - Utils.showLinkerCursor() - }) - }, - undo: function() { - var b = this.undoStack.pop(); - if (b == null) { - return - } - this.doWithoutUndo(function() { - MessageSource.beginBatch(); - for (var k = 0; k < b.length; k++) { - var h = b[k]; - if (h.action == "create") { - Utils.unselect(); - Model.remove(h.content, false) - } else { - if (h.action == "update") { - var a = h.content.shapes; - Model.updateMulti(a); - for (var l = 0; l < a.length; l++) { - var i = a[l]; - Designer.painter.renderShape(i) - } - var j = Utils.getSelectedIds(); - Utils.unselect(); - Utils.selectShape(j, false) - } else { - if (h.action == "remove") { - var a = h.content; - Model.addMulti(a); - for (var l = 0; l < a.length; l++) { - var i = a[l]; - Designer.painter.renderShape(i) - } - } else { - if (h.action == "updatePage") { - Model.updatePage(h.content.page) - } - } - } - } - } - MessageSource.commit() - }) - }, - redo: function() { - var b = this.redoStack.pop(); - if (b == null) { - return - } - this.doWithoutUndo(function() { - MessageSource.executeMessages(b, false) - }) - }, - executeMessages: function(p, l) { - MessageSource.beginBatch(); - for (var o = 0; o < p.length; o++) { - var r = p[o]; - if (r.action == "create") { - var s = r.content; - if (l) { - for (var m = 0; m < s.length; m++) { - var n = s[m]; - if (n.name != "linker") { - Schema.initShapeFunctions(n) - } - } - } - Model.addMulti(s); - for (var m = 0; m < s.length; m++) { - var n = s[m]; - Designer.painter.renderShape(n) - } - Model.build() - } else { - if (r.action == "update") { - var i = r.content.updates; - for (var m = 0; m < i.length; m++) { - var q = i[m]; - if (l && q.name != "linker") { - Schema.initShapeFunctions(q) - } - Designer.painter.renderShape(q) - } - Model.updateMulti(i); - var t = Utils.getSelectedIds(); - Utils.unselect(); - Utils.selectShape(t) - } else { - if (r.action == "remove") { - Utils.unselect(); - Model.remove(r.content) - } else { - if (r.action == "updatePage") { - Model.updatePage(r.content.update) - } - } - } - } - } - MessageSource.commit() - }, - doWithoutUndo: function(b) { - this.withUndo = false; - b(); - this.withUndo = true - }, - doWithoutMessage: function(b) { - this.withMessage = false; - b(); - this.withMessage = true - }, - doWithoutUpdateDock: function(b) { - this.withDock = false; - b(); - this.withDock = true - } -}; -Number.prototype.toScale = function() { - return this * Designer.config.scale -}; -Number.prototype.restoreScale = function() { - return this / Designer.config.scale -}; \ No newline at end of file +Schema.init(true);Schema.initMarkers();$(function(){if(role=="trial"){Designer.status="demo"}else{if(role=="viewer"){Designer.status="readonly"}else{if(role=="running"){Designer.status="running"}}}Designer.init();UI.init();Dock.init();Navigator.init();if(Designer.status=="readonly"){Designer.setReadonly(true);$("#moreShapes").hide();Customize.init();return}if(Designer.status=="demo"){UI.gettingStart()}});var Designer={config:{panelItemWidth:30,panelItemHeight:30,pageMargin:10,anchorSize:8,rotaterSize:9,anchorColor:"#833",selectorColor:"#833",scale:1},status:"",initialize:{initialized:false,initLayout:function(){$(window).bind("resize.designer",function(){showPainting();var b=$(window).height()-$("#designer_header").outerHeight()-$("#designer_footer").outerHeight();$(".layout").height(b);if($("#demo_signup").length){$("#designer_layout").height(b-$("#demo_signup").outerHeight())}});$(window).trigger("resize.designer")},initModel:function(){Model.define={page:Utils.copy(Schema.pageDefaults),elements:{}};if(definition!=undefined&&definition.localAttribute!=undefined){Model.define.localAttribute=definition.localAttribute}else{Model.define.localAttribute={}}if(definition!=undefined&&definition.commonShapeConfig!=undefined){Model.define.commonShapeConfig=definition.commonShapeConfig}else{Model.define.commonShapeConfig={}}Model.persistence={page:Utils.copy(Schema.pageDefaults),elements:{},localAttribute:{},commonShapeConfig:{}}},initCanvas:function(){var q=Model.define.page.width.toScale();var v=Model.define.page.height.toScale();var B=Model.define.page.backgroundColor;var s=Utils.getDarkerColor(B);var A=Utils.getDarkestColor(B);$("#designer_canvas").css({"background-color":"rgb("+s+")"});var w=$("#designer_grids");w.attr({width:q,height:v});var h=w[0].getContext("2d");h.clearRect(0,0,q,v);var r=Model.define.page.padding.toScale();var y=q-r*2;var p=v-r*2;h.fillStyle="rgb("+B+")";h.beginPath();h.rect(r,r,y,p);h.fill();var x=Math.round(Model.define.page.gridSize.toScale());if(x<10){x=10}if(Model.define.page.showGrid){h.translate(r,r);h.lineWidth=1;h.save();var t=0.5;var u=0;while(t<=p){h.restore();if(u%4==0){h.strokeStyle="rgb("+A+")"}else{h.strokeStyle="rgb("+s+")"}h.beginPath();h.moveTo(0,t);h.lineTo(y,t);t+=x;u++;h.stroke()}t=0.5;u=0;while(t<=y){h.restore();if(u%4==0){h.strokeStyle="rgb("+A+")"}else{h.strokeStyle="rgb("+s+")"}h.beginPath();h.moveTo(t,0);h.lineTo(t,p);t+=x;u++;h.stroke()}}$("#canvas_container").css({width:q,height:v,padding:Designer.config.pageMargin});if(!this.initialized){$("#designer_layout").scrollTop(Designer.config.pageMargin-10);$("#designer_layout").scrollLeft(Designer.config.pageMargin-10)}var z=$("#bar_list_page").children("li[ac=set_page_showgrid]");z.menuitem("unselect");if(Model.define.page.showGrid){z.menuitem("select")}},initShapes:function(){$("#shape_panel").empty();for(var o=0;o

    "+n.text+"

    ")}$(".panel_title").unbind().bind("click",function(){$(this).parent().toggleClass("panel_collapsed")});for(var s in Schema.shapes){var l=Schema.shapes[s];if(l.attribute.visible&&l.category!="standard"){if((l.category=="process_bpmn2"||l.category=="process.bpmn2"||l.category=="bpmn")&&checkRunningTimeShape(l)){continue}if(!l.groupName){p(l)}else{var i=SchemaGroup.getGroup(l.groupName);if(i[0]==s){p(l,l.groupName)}}}}function p(b,d){b=Utils.copy(b);var e="
    ";var c=$(e).appendTo("#panel_"+b.category);if(d){c.append("
    ")}var a=c.children()[0];c.bind("mouseenter",function(){if($(this).hasClass("readonly")){return}var h=$("#shape_thumb");var title=b.title;var category=b.category;if(b.category=="bpmn"){category='process_bpmn2'}if(category=='lane'){category=methodId}category=category.replace(/_/g,".");if(methodObjectDesc[category+'-'+b.name]){title+=(':'+methodObjectDesc[category+'-'+b.name])}h.children("div").text(title);var j=h.children("canvas")[0].getContext("2d");var A={x:0,y:0,w:b.props.w,h:b.props.h,angle:b.props.angle};var y=160;var k=160;j.clearRect(0,0,y,k);if(b.props.w>=b.props.h){if(b.props.w>y){A.w=y;A.h=parseInt(b.props.h/b.props.w*A.w)}}else{if(b.props.h>k){A.h=k;A.w=parseInt(b.props.w/b.props.h*A.h)}}h.children("canvas").attr({width:y+20,height:A.h+20});h.show();b.props=A;j.save();if(b.name!="text"&&b.name!="umlText"){j.globalAlpha=b.shapeStyle.alpha;var f=(y+20-A.w)/2;var g=10;j.translate(f,g);j.translate(A.w/2,A.h/2);j.rotate(A.angle);j.translate(-(A.w/2),-(A.h/2));Designer.painter.renderShapePath(j,b,true);Designer.painter.renderMarkers(j,b,true)}else{j.translate(y/2+10,A.h/2+10);j.textBaseline="middle";j.textAlign="center";var B="";if(b.fontStyle.italic){B+="italic "}else{B+="normal "}if(b.fontStyle.bold){B+="bold "}else{B+="normal "}B+=b.fontStyle.size+"pt ";B+=b.fontStyle.fontFamily;j.font=B;j.fillStyle="rgb("+b.fontStyle.color+")";j.fillText(b.text,0,0)}j.restore();var z=c.offset().top-$("#designer_header").outerHeight()+c.height()/2-h.outerHeight()/2;if(z<5){z=5}else{if(z+h.outerHeight()>$("#designer_viewport").height()-5){z=$("#designer_viewport").height()-5-h.outerHeight()}}h.css("top",z)}).bind("mouseleave",function(){$("#shape_thumb").hide()});Designer.painter.drawPanelItem(a,b.name)}r();function r(){$(".panel_box").die().live("mousedown",function(j){var c=$(this);if(c.hasClass("readonly")){return}var h=c.attr("shapeName");var a=[];Designer.op.changeState("creating_from_panel");var g=null;var b=null;var d=$("#designer_canvas");var f=t(h);$("#designer").bind("mousemove.creating",function(k){m(f,k)});$("#canvas_container").bind("mousemove.create",function(B){var D=Utils.getRelativePos(B.pageX,B.pageY,d);if(g==null){g=q(h,D.x,D.y);b=$("#"+g.id);b.attr("class","shape_box_creating")}b.css({left:D.x-b.width()/2+"px",top:D.y-b.height()/2+"px","z-index":Model.orderList.length});g.props.x=D.x.restoreScale()-g.props.w/2;g.props.y=D.y.restoreScale()-g.props.h/2;var G=g.props;var H=Designer.op.snapLine(G,[g.id],true,g);if(H.attach){g.attachTo=H.attach.id}else{delete g.attachTo}b.css({left:(g.props.x-10).toScale()+"px",top:(g.props.y-10).toScale()+"px","z-index":Model.orderList.length});a=Utils.getShapeAnchorInLinker(g);Designer.op.hideLinkPoint();for(var C=0;C").appendTo("#designer");b=$("").appendTo(c)}c.css({left:"0px",top:"0px",width:$(".panel_container").width(),height:$("#shape_panel").outerHeight()});Designer.painter.drawPanelItem(b[0],a);return b}function m(b,a){$("#creating_shape_container").show();var c=Utils.getRelativePos(a.pageX,a.pageY,$("#creating_shape_container"));b.css({left:c.x-Designer.config.panelItemWidth/2,top:c.y-Designer.config.panelItemHeight/2})}function q(g,e,f){var h=Utils.newId();var b=Schema.shapes[g];var c=e.restoreScale()-b.props.w/2;var d=f.restoreScale()-b.props.h/2;var a=Model.create(g,c,d);Designer.painter.renderShape(a);return a}}},hotkey:{init:function(){var b=null;$(document).unbind("keydown.hotkey").bind("keydown.hotkey",function(n){if(n.ctrlKey&&n.keyCode==65){Designer.selectAll();n.preventDefault()}else{if(n.keyCode==46||n.keyCode==8){Designer.op.removeShape();n.preventDefault()}else{if(n.ctrlKey&&n.keyCode==90){MessageSource.undo();n.preventDefault()}else{if(n.ctrlKey&&n.keyCode==89){MessageSource.redo();n.preventDefault()}else{if(n.ctrlKey&&!n.shiftKey&&n.keyCode==67){Designer.clipboard.copy();n.preventDefault()}else{if(n.ctrlKey&&n.keyCode==88){Designer.clipboard.cut();n.preventDefault()}else{if(n.ctrlKey&&n.keyCode==86){Designer.clipboard.paste();n.preventDefault()}else{if(n.ctrlKey&&n.keyCode==68){Designer.clipboard.duplicate();n.preventDefault()}else{if(n.ctrlKey&&n.shiftKey&&n.keyCode==66){Designer.clipboard.brush();n.preventDefault()}else{if(n.ctrlKey&&n.keyCode==190){Designer.zoomIn();n.preventDefault()}else{if(n.ctrlKey&&n.keyCode==188){Designer.zoomOut();n.preventDefault()}else{if(n.keyCode>=37&&n.keyCode<=40){if(b==null){var s=Utils.getSelected();var m=Utils.getFamilyShapes(s);s=s.concat(m);var q=Utils.getContainedShapes(s);s=s.concat(q);var r=Utils.getAttachedShapes(s);s=s.concat(r);var a=Utils.getOutlinkers(s);b=s.concat(a)}if(b.length>0){n.preventDefault();var t=10;if(n.ctrlKey){t=1}Utils.hideLinkerCursor();if(n.keyCode==37){Designer.op.moveShape(b,{x:-t,y:0})}else{if(n.keyCode==38){Designer.op.moveShape(b,{x:0,y:-t})}else{if(n.keyCode==39){Designer.op.moveShape(b,{x:t,y:0})}else{if(n.keyCode==40){Designer.op.moveShape(b,{x:0,y:t})}}}}$(document).unbind("keyup.moveshape").bind("keyup.moveshape",function(){Model.updateMulti(b);b=null;$(document).unbind("keyup.moveshape");Designer.op.hideTip();Utils.showLinkerCursor()})}}else{if(n.keyCode==221&&n.ctrlKey){var e="front";if(n.shiftKey){e="forward"}Designer.layerShapes(e)}else{if(n.keyCode==219&&n.ctrlKey){var e="back";if(n.shiftKey){e="backward"}Designer.layerShapes(e)}else{if(n.keyCode==71&&n.ctrlKey){n.preventDefault();if(n.shiftKey){Designer.ungroup()}else{Designer.group()}}else{if(n.keyCode==76&&n.ctrlKey){n.preventDefault();if(n.shiftKey){Designer.unlockShapes()}else{Designer.lockShapes()}}else{if(n.keyCode==18){Designer.op.changeState("drag_canvas")}else{if(n.keyCode==27){if(!Designer.op.state){Utils.unselect();$(".menu.list").hide();$(".menu").hide();$(".color_picker").hide()}else{if(Designer.op.state=="creating_free_text"||Designer.op.state=="creating_free_linker"){Designer.op.resetState()}}}else{if(n.keyCode==84&&!n.ctrlKey){$(".menu.list").hide();Designer.op.changeState("creating_free_text")}else{if(n.keyCode==73&&!n.ctrlKey){$(".menu.list").hide();UI.showImageSelect(function(c,d,f){UI.insertImage(c,d,f)});$("#designer_contextmenu").hide()}else{if(n.keyCode==76&&!n.ctrlKey){$(".menu.list").hide();Designer.op.changeState("creating_free_linker");$("#designer_contextmenu").hide()}else{if(n.keyCode==66&&n.ctrlKey){var o=Utils.getSelectedIds();if(o.length>0){var p=Model.getShapeById(o[0]);Designer.setFontStyle({bold:!p.fontStyle.bold});UI.update()}}else{if(n.keyCode==73&&n.ctrlKey){var o=Utils.getSelectedIds();if(o.length>0){var p=Model.getShapeById(o[0]);Designer.setFontStyle({italic:!p.fontStyle.italic});UI.update()}}else{if(n.keyCode==85&&n.ctrlKey){var o=Utils.getSelectedIds();if(o.length>0){var p=Model.getShapeById(o[0]);Designer.setFontStyle({underline:!p.fontStyle.underline});UI.update()}n.preventDefault()}else{if(n.keyCode==32&&!n.ctrlKey){var o=Utils.getSelectedIds();if(o.length==1){var p=Model.getShapeById(o[0]);Designer.op.editShapeText(p)}n.preventDefault()}else{if(n.keyCode==121){n.preventDefault();Dock.enterPresentation()}}}}}}}}}}}}}}}}}}}}}}}}}}});$("input,textarea,select").die().live("keydown.hotkey",function(a){a.stopPropagation()})},cancel:function(){$(document).unbind("keydown.hotkey")}},contextMenu:{init:function(){$("#designer_contextmenu").unbind("mousedown").bind("mousedown",function(b){b.stopPropagation()});$("#designer_contextmenu").find("li:not(.devider)").unbind("click").bind("click",function(){var b=$(this);if(!b.menuitem("isDisabled")&&b.children(".extend_menu").length==0){Designer.contextMenu.execAction(b);Designer.contextMenu.hide()}});$("#canvas_container").unbind("contextmenu").bind("contextmenu",function(d){d.preventDefault();var e=$("#designer_canvas");var f=Utils.getRelativePos(d.pageX,d.pageY,e);Designer.contextMenu.show(f.x,f.y)})},destroy:function(){$("#canvas_container").unbind("contextmenu");this.hide()},menuPos:{x:0,y:0,shape:null},show:function(k,l){this.menuPos.x=k;this.menuPos.y=l;var p=$("#designer_contextmenu");var r=Utils.getShapeByPosition(k,l,false);p.children().hide();p.children("li[ac=selectall]").show();p.children(".devi_selectall").show();p.children("li[ac=drawline]").show();var q=Designer.clipboard.elements.length;if(r==null){if(q>0){p.children("li[ac=paste]").show();p.children(".devi_clip").show()}}else{var n=r.shape;this.menuPos.shape=n;if(n.locked){if(q>0){p.children("li[ac=paste]").show();p.children(".devi_clip").show()}p.children("li[ac=unlock]").show();p.children(".devi_shape").show()}else{p.children("li[ac=cut]").show();p.children("li[ac=copy]").show();p.children("li[ac=duplicate]").show();if(q>0){p.children("li[ac=paste]").show()}p.children(".devi_clip").show();p.children("li[ac=front]").show();p.children("li[ac=back]").show();p.children("li[ac=lock]").show();var m=Utils.getSelectedIds();var o=m.length;if(o>=2){p.children("li[ac=group]").show();$("#ctxmenu_align").show()}var j=Utils.getSelectedGroups().length;if(j>=1){p.children("li[ac=ungroup]").show()}p.children(".devi_shape").show();if(o==1&&n.name!="linker"&&n.link){p.children("li[ac=changelink]").show()}if(n.name=="linker"||n.attribute.editable){p.children("li[ac=edit]").show()}p.children("li[ac=delete]").show();p.children(".devi_del").show()}}p.css({display:"block","z-index":Model.orderList.length+3,left:k,top:l});$(document).bind("mousedown.ctxmenu",function(){Designer.contextMenu.hide()})},hide:function(){$("#designer_contextmenu").hide();$(document).unbind("mousedown.ctxmenu")},execAction:function(e){var d=e.attr("ac");if(d=="cut"){Designer.clipboard.cut()}else{if(d=="copy"){Designer.clipboard.copy()}else{if(d=="paste"){Designer.clipboard.paste(this.menuPos.x,this.menuPos.y)}else{if(d=="duplicate"){Designer.clipboard.duplicate()}else{if(d=="front"){Designer.layerShapes("front")}else{if(d=="back"){Designer.layerShapes("back")}else{if(d=="lock"){Designer.lockShapes()}else{if(d=="unlock"){Designer.unlockShapes()}else{if(d=="group"){Designer.group()}else{if(d=="ungroup"){Designer.ungroup()}else{if(d=="align_shape"){var f=e.attr("al");Designer.alignShapes(f)}else{if(d=="edit"){Designer.op.editShapeText(this.menuPos.shape)}else{if(d=="delete"){Designer.op.removeShape()}else{if(d=="selectall"){Designer.selectAll()}else{if(d=="drawline"){Designer.op.changeState("creating_free_linker")}else{if(d=="changelink"){UI.showInsertLink()}}}}}}}}}}}}}}}}}},init:function(){this.initialize.initLayout();this.initialize.initModel();this.initialize.initCanvas();this.initialize.initShapes();this.hotkey.init();this.contextMenu.init();Designer.op.init();this.initialize.initialized=true;Designer.events.push("initialized");$("#designer_layout").on("scroll",function(){$(document).trigger("mouseup.multiselect")})},op:{init:function(){var c=$("#designer_canvas");var d=$("#canvas_container");d.unbind("mousemove.operate").bind("mousemove.operate",function(a){if(Designer.op.state!=null){return}Designer.op.destroy();var b=Utils.getRelativePos(a.pageX,a.pageY,c);var j=Utils.getShapeByPosition(b.x,b.y);if(j!=null){if(j.type=="dataAttribute"){}else{if(j.type=="linker"){d.css("cursor","pointer");Designer.op.shapeSelectable(j.shape);var h=j.shape;var i=j.pointIndex;if(h.linkerType=="broken"&&i>1&&i<=h.points.length){Designer.op.brokenLinkerChangable(h,i-1)}else{if(h.from.id==null&&h.to.id==null){d.css("cursor","move");Designer.op.shapeDraggable()}}Designer.op.linkerEditable(h)}else{if(j.type=="linker_point"){d.css("cursor","move");Designer.op.shapeSelectable(j.shape);Designer.op.linkerDraggable(j.shape,j.point);Designer.op.linkerEditable(j.shape)}else{if(j.type=="linker_text"){d.css("cursor","text");Designer.op.shapeSelectable(j.shape);Designer.op.linkerEditable(j.shape)}else{if(j.type=="shape"){if(j.shape.locked){d.css("cursor","default");Designer.op.shapeSelectable(j.shape)}else{d.css("cursor","move");Designer.op.shapeSelectable(j.shape);Designer.op.shapeEditable(j.shape);Designer.op.shapeDraggable();if(j.shape.link){}}}else{d.css("cursor","crosshair");Designer.op.shapeSelectable(j.shape);Designer.op.shapeLinkable(j.shape,j.linkPoint)}if(j.shape.parent){Utils.showAnchors(Model.getShapeById(j.shape.parent))}else{Utils.showAnchors(j.shape)}}}}}}else{d.css("cursor","default");Designer.op.shapeMultiSelectable()}})},cancel:function(){$("#canvas_container").unbind("mousemove.operate").css("cursor","default");this.destroy()},destroy:function(){$("#designer_canvas").unbind("mousedown.drag").unbind("dblclick.edit").unbind("mousedown.draglinker").unbind("mousedown.select").unbind("mousedown.brokenLinker").unbind("dblclick.edit_linker");$("#canvas_container").unbind("mousedown.link").unbind("mousedown.create_text").unbind("mousedown.drag_canvas");$("#designer_layout").unbind("mousedown.multiselect");Utils.hideAnchors();$("#link_spot").hide()},state:null,changeState:function(b){this.state=b;if(b=="creating_free_text"){this.destroy();$("#canvas_container").css("cursor","crosshair");this.textCreatable()}else{if(b=="creating_free_linker"){this.destroy();$("#canvas_container").css("cursor","crosshair");this.shapeLinkable()}else{if(b=="drag_canvas"){this.destroy();this.canvasDraggable()}else{if(b=="changing_curve"){this.destroy()}}}}},resetState:function(){this.state=null;$("#canvas_container").css("cursor","default")},shapeSelectable:function(d){var c=$("#designer_canvas");c.bind("mousedown.select",function(b){Designer.op.changeState("seelcting_shapes");var a=d.id;var f=[];if(b.ctrlKey){var f=Utils.getSelectedIds();if(Utils.isSelected(a)){Utils.removeFromArray(f,a)}else{f.push(a)}Utils.unselect();if(f.length>0){Utils.selectShape(f)}}else{if(Utils.selectIds.indexOf(a)<0){Utils.unselect();Utils.selectShape(a)}}$(document).bind("mouseup.select",function(){Designer.op.resetState();c.unbind("mousedown.select");$(document).unbind("mouseup.select")})})},shapeDraggable:function(){var c=$("#designer_canvas");var d=$("#canvas_container");c.bind("mousedown.drag",function(b){Utils.hideLinkerCursor();Utils.hideLinkerControls();Designer.op.changeState("dragging");var x=Utils.getRelativePos(b.pageX,b.pageY,c);var u=Utils.getSelected();var w=true;if(u.length==1&&u[0].name=="linker"){w=false}var z=null;if(w){z=Utils.getShapesBounding(u)}var i=Utils.getFamilyShapes(u);u=u.concat(i);var r=Utils.getContainedShapes(u);u=u.concat(r);var s=Utils.getAttachedShapes(u);u=u.concat(s);var y=[];if(w){for(var t=0;tpageSize.width-pageSize.padding){Designer.setPageStyle({width:shapePosition.x+shapePosition.w+pageSize.padding+30});$("#page_size_w").spinner('value',shapePosition.x+shapePosition.w+pageSize.padding+30)}if(shapePosition.y+shapePosition.h>pageSize.height-pageSize.padding){Designer.setPageStyle({height:shapePosition.y+shapePosition.h+pageSize.padding+30});$("#page_size_h").spinner('value',shapePosition.x+shapePosition.w+pageSize.padding+30)}}if(isAutoSave=="0"){$("#saving_tip").css("color","rgb(255, 0, 0)");$("#saving_tip").text("文件已修改,未保存")}})})},shapeResizable:function(){$(".shape_controller").bind("mousedown",function(ab){if(!isAdmin&&isCustomDefine=="1"){var ae=Utils.getSelected();var P=true;for(var p=0;p=0){E.x=M.x+M.w}else{if(N.indexOf("r")>=0){E.x=M.x}else{E.x=M.x+M.w/2}}if(N.indexOf("t")>=0){E.y=M.y+M.h}else{if(N.indexOf("b")>=0){E.y=M.y}else{E.y=M.y+M.h/2}}E=Utils.getRotated(C,E,M.angle);function G(a,b){if(a.id==null){if(b){return{type:"box",x:(a.x-M.x)/M.w,y:(a.y-M.y)/M.h}}else{return{type:"fixed"}}}else{if(Utils.isSelected(a.id)){var e=Model.getShapeById(a.id);var d={x:e.props.x+e.props.w/2,y:e.props.y+e.props.h/2};var c=Utils.getRotated(d,a,-e.props.angle);return{type:"shape",x:(c.x-e.props.x)/e.props.w,y:(c.y-e.props.y)/e.props.h}}else{return{type:"fixed"}}}}var W=[];var ac={};var Z=[];var L=Utils.getAttachedShapes(K);K=K.concat(L);var J=[];for(var H=0;H0){for(var T=0;T=0){w.w=k.x-E.x}else{if(N.indexOf("l")>=0){w.w=E.x-k.x}}if(N.indexOf("b")>=0){w.h=k.y-E.y}else{if(N.indexOf("t")>=0){w.h=E.y-k.y}}if(a.ctrlKey&&N.length==2){if(M.w>=M.h){w.h=M.h/M.w*w.w;if(w.h=0){d.x=E.x+w.w}else{if(N.indexOf("l")>=0){d.x=E.x-w.w}else{d.x=E.x}}if(N.indexOf("b")>=0){d.y=E.y+w.h}else{if(N.indexOf("t")>=0){d.y=E.y-w.h}else{d.y=E.y}}var o=Utils.getRotated(E,d,M.angle);var m={x:0.5*E.x+0.5*o.x,y:0.5*E.y+0.5*o.y};var f=Utils.getRotated(m,E,-M.angle);if(N.indexOf("r")>=0){w.x=f.x}else{if(N.indexOf("l")>=0){w.x=f.x-w.w}else{w.x=f.x-w.w/2}}if(N.indexOf("b")>=0){w.y=f.y}else{if(N.indexOf("t")>=0){w.y=f.y-w.h}else{w.y=f.y-w.h/2}}if(w.angle==0){var y=W[0];var h=Designer.op.snapResizeLine(w,J,N)}Utils.removeAnchors();for(var e=0;e"+r}Designer.op.showTip(r);$(document).unbind("mouseup.resize_ok").bind("mouseup.resize_ok",function(){if(F.length>0){W=W.concat(F)}Model.updateMulti(W);$(document).unbind("mouseup.resize_ok")})});$(document).bind("mouseup.resize",function(){S.css("cursor","default");Designer.op.resetState();S.unbind("mousemove.resize");$(document).unbind("mouseup.resize");var selectedShape=Utils.getSelected()[0];if(selectedShape){var shapePosition=selectedShape.props;var pageSize=Model.define.page;if(shapePosition.x+shapePosition.w>pageSize.width-pageSize.padding){Designer.setPageStyle({width:shapePosition.x+shapePosition.w+pageSize.padding+10})}if(shapePosition.y+shapePosition.h>pageSize.height-pageSize.padding){Designer.setPageStyle({height:shapePosition.y+shapePosition.h+pageSize.padding+10})}}Designer.op.hideTip();Utils.showLinkerCursor();Designer.op.hideSnapLine()})})},shapeRotatable:function(){$(".shape_rotater").bind("mousemove",function(i){var j=$(this);var g=i.pageX-j.offset().left;var h=i.pageY-j.offset().top;var e=j[0].getContext("2d");j.unbind("mousedown");j.removeClass("rotate_enable");if(e.isPointInPath(g,h)){j.addClass("rotate_enable");j.bind("mousedown",function(b){Utils.hideLinkerCursor();if($("#shape_text_edit").length){$("#shape_text_edit").trigger("blur")}b.stopPropagation();Designer.op.changeState("rotating");var r=Utils.getSelectedIds();var c;var s;if(r.length==1){var f=Model.getShapeById(r[0]);c=f.props;s=f.props.angle}else{c=Utils.getControlBox(r);s=0}var x={x:c.x+c.w/2,y:c.y+c.h/2};var d=Utils.toScale(x);var w=$("#designer_canvas");var u=Utils.getSelected();var t=Utils.getAttachedShapes(u);u=u.concat(t);var a=Utils.getOutlinkers(u);u=u.concat(a);var v=s;$(document).bind("mousemove.rotate",function(l){var m=Utils.getRelativePos(l.pageX,l.pageY,w);var H=Math.atan(Math.abs(m.x-d.x)/Math.abs(d.y-m.y));if(m.x>=d.x&&m.y>=d.y){H=Math.PI-H}else{if(m.x<=d.x&&m.y>=d.y){H=Math.PI+H}else{if(m.x<=d.x&&m.y<=d.y){H=Math.PI*2-H}}}H=H%(Math.PI*2);var k=Math.PI/36;var o=Math.round(H/k);H=k*o;if(H==v){return}v=H;Designer.op.showTip(o*5%360+"°");Designer.painter.rotateControls(c,H);Utils.removeAnchors();var L=H-s;for(var G=0;G0){for(var b2xi in Model.define.localAttribute[c]){b2x.attributesJsonArray.push(Utils.copy(Model.define.localAttribute[c][b2xi]))}}for(var pj=0;pj0){a=a.concat(b)}Model.updateMulti(a)}})})},shapeMultiSelectable:function(){var d=$("#designer_canvas");var c=$("#designer_layout");c.unbind("mousedown.multiselect").bind("mousedown.multiselect",function(a){var b=null;if(!a.ctrlKey){Utils.unselect()}var f=Utils.getRelativePos(a.pageX,a.pageY,d);Designer.op.changeState("multi_selecting");c.bind("mousemove.multiselect",function(i){if(b==null){b=$("
    ").appendTo(d)}var j=Utils.getRelativePos(i.pageX,i.pageY,d);var e={"z-index":Model.orderList.length,left:j.x,top:j.y};if(j.x>f.x){e.left=f.x}if(j.y>f.y){e.top=f.y}e.width=Math.abs(j.x-f.x);e.height=Math.abs(j.y-f.y);b.css(e)});$(document).unbind("mouseup.multiselect").bind("mouseup.multiselect",function(j){if(b!=null){var l={x:b.position().left.restoreScale(),y:b.position().top.restoreScale(),w:b.width().restoreScale(),h:b.height().restoreScale()};var e=Utils.getShapesByRange(l);if(j.ctrlKey){var k=Utils.getSelectedIds();Utils.mergeArray(e,k)}Utils.unselect();Utils.selectShape(e);b.remove()}Designer.op.resetState();$(document).unbind("mouseup.multiselect");c.unbind("mousemove.multiselect")});c.unbind("mousedown.multiselect")})},shapeEditable:function(d){var c=$("#designer_canvas");if(d.attribute.editable==false){return}c.unbind("dblclick.edit").bind("dblclick.edit",function(){Designer.op.editShapeText(d);c.unbind("dblclick.edit")})},editShapeText:function(o){if(o.name=="linker"){this.editLinkerText(o);return}var j=$("#shape_text_edit");if(j.length==0){j=$("").appendTo("#designer_canvas")}var k=$("#shape_text_ruler");if(k.length==0){k=$("").appendTo("#designer_canvas")}$(".text_canvas[forshape="+o.id+"]").hide();var l=o.fontStyle;var p=o.getTextBlock();if(l.orientation=="horizontal"){var m={x:p.x+p.w/2,y:p.y+p.h/2};p={x:m.x-p.h/2,y:m.y-p.w/2,w:p.h,h:p.w}}var n={width:p.w+"px","z-index":Model.orderList.length+2,"line-height":Math.round(l.size*1.25)+"px","font-size":l.size+"px","font-family":l.fontFamily,"font-weight":l.bold?"bold":"normal","font-style":l.italic?"italic":"normal","text-align":l.textAlign,color:"rgb("+l.color+")","text-decoration":l.underline?"underline":"none"};j.css(n);k.css(n);j.show();p.x+=o.props.x;p.y+=o.props.y;j.val(o.text);$("#shape_text_edit").unbind().bind("keyup",function(){var a=$(this).val();k.val(a);k.scrollTop(99999);var h=k.scrollTop();j.css({height:h});var g={x:p.x+p.w/2,y:p.y+p.h/2};var f=0;var d=0;var w=p.h;if(o.fontStyle.vAlign=="middle"){if(h>w){w=h;f=(g.y-w/2);d=0}else{f=(g.y-p.h/2);d=(p.h-h)/2;w=p.h-d}}else{if(o.fontStyle.vAlign=="bottom"){if(h>w){w=h;f=(g.y+p.h/2-w);d=0}else{f=(g.y-p.h/2);d=p.h-h;w=p.h-d}}else{f=(g.y-p.h/2);d=0;if(h>w){w=h}else{w=p.h}}}var x=d+w;var b={x:p.x+p.w/2,y:f+x/2};var c=o.props.angle;if(c!=0){var v={x:o.props.x+o.props.w/2,y:o.props.y+o.props.h/2};b=Utils.getRotated(v,b,c)}if(l.orientation=="horizontal"){c=(Math.PI*1.5+c)%(Math.PI*2)}var u=Math.round(c/(Math.PI*2)*360);var e="rotate("+u+"deg) scale("+Designer.config.scale+")";j.css({width:p.w,height:w,"padding-top":d,left:b.x.toScale()-p.w/2-2,top:b.y.toScale()-x/2-2,"-webkit-transform":e,"-ms-transform":e,"-o-transform":e,"-moz-transform":e,transform:e})}).bind("keydown",function(a){var d=$(this);if(a.keyCode==13&&a.ctrlKey){i();return false}else{if(a.keyCode==27){d.unbind().remove();$(".text_canvas[forshape="+o.id+"]").show()}else{if(a.keyCode==66&&a.ctrlKey){var c=!o.fontStyle.bold;o.fontStyle.bold=c;Model.update(o);var b=c?"bold":"normal";$(this).css("font-weight",b);k.css("font-weight",b);UI.update()}else{if(a.keyCode==73&&a.ctrlKey){var c=!o.fontStyle.italic;o.fontStyle.italic=c;Model.update(o);var b=c?"italic":"normal";$(this).css("font-style",b);k.css("font-style",b);UI.update()}else{if(a.keyCode==85&&a.ctrlKey){var c=!o.fontStyle.underline;o.fontStyle.underline=c;Model.update(o);var b=c?"underline":"none";$(this).css("text-decoration",b);k.css("text-decoration",b);a.preventDefault();UI.update()}}}}}}).bind("blur",function(a){i()}).bind("mousemove",function(a){a.stopPropagation()}).bind("mousedown",function(a){a.stopPropagation()}).bind("mouseenter",function(a){Designer.op.destroy()});$("#shape_text_edit").trigger("keyup");j.select();function i(){var a=$("#shape_text_edit").val();if($("#shape_text_edit").length&&$("#shape_text_edit").is(":visible")){if(a!=o.text){o.text=a;Model.update(o)}Designer.painter.renderShape(o);$("#shape_text_edit").remove()}}},shapeLinkable:function(j,g){var i=$("#designer_canvas");var f=$("#canvas_container");f.unbind("mousedown.link").bind("mousedown.link",function(c){Designer.op.changeState("linking_from_shape");var e=null;var d=null;var a;if(!j){var b=Utils.getRelativePos(c.pageX,c.pageY,i);a={x:b.x.restoreScale(),y:b.y.restoreScale(),id:null,angle:null}}else{a=g;a.id=j.id}f.bind("mousemove.link",function(m){f.css("cursor","default");var n=Utils.getRelativePos(m.pageX,m.pageY,i);if(d==null){d=h(a,n);Designer.events.push("linkerCreating",d)}Designer.op.moveLinker(d,"to",n.x,n.y);$(document).unbind("mouseup.droplinker").bind("mouseup.droplinker",function(){if(Math.abs(n.x-a.x)>20||Math.abs(n.y-a.y)>20){Model.add(d);Designer.events.push("linkerCreated",d);if(d.to.id==null&&d.from.id!=null){Designer.op.linkDashboard(d)}Utils.showLinkerCursor()}else{$("#"+d.id).remove()}$(document).unbind("mouseup.droplinker")})});$(document).bind("mouseup.link",function(){Designer.op.hideLinkPoint();Designer.op.resetState();f.unbind("mousedown.link");f.unbind("mousemove.link");$(document).unbind("mouseup.link")})});function h(a,b){var d=Utils.newId();var c=Utils.copy(Schema.linkerDefaults);c.from=a;c.to={id:null,x:b.x,y:b.y,angle:null};c.props={zindex:Model.maxZIndex+1};c.id=d;return c}},linkerEditable:function(c){var d=$("#designer_canvas");d.unbind("dblclick.edit_linker").bind("dblclick.edit_linker",function(){Designer.op.editLinkerText(c);d.unbind("dblclick.edit_linker")})},editLinkerText:function(n){Designer.contextMenu.hide();var o=Designer.painter.getLinkerMidpoint(n);var k=$("#"+n.id).find(".text_canvas");var i=$("#linker_text_edit");if(i.length==0){i=$("").appendTo("#designer_canvas")}$("#"+n.id).find(".text_canvas").hide();var l=n.fontStyle;var m="scale("+Designer.config.scale+")";var j=Math.round(l.size*1.25);i.css({"z-index":Model.orderList.length,"line-height":j+"px","font-size":l.size+"px","font-family":l.fontFamily,"font-weight":l.bold?"bold":"normal","font-style":l.italic?"italic":"normal","text-align":l.textAlign,color:"rgb("+l.color+")","text-decoration":l.underline?"underline":"none","-webkit-transform":m,"-ms-transform":m,"-o-transform":m,"-moz-transform":m,transform:m});i.val(n.text).show().select();i.unbind().bind("keyup",function(){var b=$(this).val();var a=b.replace(//g,">").replace(/\n/g,"
    ");k.html(a+"
    ");var d=k.width();if(d<50){d=50}var c=k.height();if(c1){a=true}e.bind("mousemove.draglinker",function(d){e.css("cursor","default");var j=Utils.getRelativePos(d.pageX,d.pageY,h);Designer.op.moveLinker(g,f,j.x,j.y);if(a){Designer.painter.drawControls(c)}$(document).unbind("mouseup.droplinker").bind("mouseup.droplinker",function(){$(document).unbind("mouseup.droplinker");Model.update(g);Utils.showLinkerControls()})});$(document).bind("mouseup.draglinker",function(){Designer.op.hideLinkPoint();Designer.op.resetState();h.unbind("mousedown.draglinker");e.unbind("mousemove.draglinker");$(document).unbind("mouseup.draglinker");Utils.showLinkerControls()})})},linkClickable:function(e,f){var d=$("#link_spot");if(d.length==0){d=$("").appendTo("#designer_canvas")}if(e.trim().toLowerCase().indexOf("http")==-1){e="http://"+e}d.show().css({left:f.x-50,top:f.y-50,"z-index":Model.orderList.length+1})},textCreatable:function(){var c=$("#designer_canvas");var d=$("#canvas_container");d.unbind("mousedown.create_text").bind("mousedown.create_text",function(a){var g=null;if(!a.ctrlKey){Utils.unselect()}var h=Utils.getRelativePos(a.pageX,a.pageY,c);var b=null;d.bind("mousemove.create_text",function(f){if(g==null){g=$("
    ").appendTo(c)}var e=Utils.getRelativePos(f.pageX,f.pageY,c);b={"z-index":Model.orderList.length,left:e.x-1,top:e.y-1};if(e.x>h.x){b.left=h.x-1}if(e.y>h.y){b.top=h.y-1}b.width=Math.abs(e.x-h.x-2);b.height=Math.abs(e.y-h.y-2);g.css(b)});$(document).unbind("mouseup.create_text").bind("mouseup.create_text",function(e){if(b!=null&&b.width>=20&&b.height>=20){var f=Model.create("standardText",b.left.restoreScale(),b.top.restoreScale());f.props.w=b.width.restoreScale();f.props.h=b.height.restoreScale();Model.add(f);Designer.painter.renderShape(f);Designer.op.editShapeText(f);Utils.unselect();Utils.selectShape(f.id)}g.remove();Designer.op.resetState();$(document).unbind("mouseup.create_text");d.unbind("mousemove.create_text")});d.unbind("mousedown.create_text")})},canvasDragTimeout:null,canvasDraggable:function(){var b=$("#canvas_container");b.css("cursor","url(../apps/_bpm.platform/js/designer/themes/default/images/diagraming/cursor_hand.png) 8 8, auto");if(this.canvasDragTimeout){clearTimeout(this.canvasDragTimeout)}this.canvasDragTimeout=setTimeout(function(){b.unbind("mousedown.drag_canvas");Designer.op.resetState();b.unbind("mousemove.drag_canvas");$(document).unbind("mouseup.drag_canvas")},500);b.unbind("mousedown.drag_canvas").bind("mousedown.drag_canvas",function(e){var f=$("#designer_layout").scrollTop();var a=$("#designer_layout").scrollLeft();b.bind("mousemove.drag_canvas",function(d){var h=d.pageX-e.pageX;var c=d.pageY-e.pageY;$("#designer_layout").scrollLeft(a-h);$("#designer_layout").scrollTop(f-c)});$(document).unbind("mouseup.drag_canvas").bind("mouseup.drag_canvas",function(c){b.unbind("mousemove.drag_canvas");$(document).unbind("mouseup.drag_canvas")})});$(document).unbind("keyup.drag_canvas").bind("keyup.drag_canvas",function(a){b.unbind("mousedown.drag_canvas");Designer.op.resetState();$(document).unbind("mouseup.drag_canvas");a.preventDefault();clearTimeout(this.canvasDragTimeout);b.unbind("mousemove.drag_canvas")})},canvasFreeDraggable:function(){var b=$("#canvas_container");b.css("cursor","url(../apps/_bpm.platform/js/designer/themes/default/images/diagraming/cursor_hand.png) 8 8, auto");b.unbind("mousedown.drag_canvas").bind("mousedown.drag_canvas",function(e){var f=$("#designer_layout").scrollTop();var a=$("#designer_layout").scrollLeft();b.bind("mousemove.drag_canvas",function(d){var h=d.pageX-e.pageX;var c=d.pageY-e.pageY;$("#designer_layout").scrollLeft(a-h);$("#designer_layout").scrollTop(f-c)});$(document).unbind("mouseup.drag_canvas").bind("mouseup.drag_canvas",function(c){b.unbind("mousemove.drag_canvas");$(document).unbind("mouseup.drag_canvas")})})},moveShape:function(A,H){var z=[];for(var x=0;x=0){D.from.x+=i.x;D.from.y+=i.y;G=true}if(L.id!=null&&z.indexOf(L.id)>=0){D.to.x+=i.x;D.to.y+=i.y;C=true}}else{if(y.id==null||z.indexOf(y.id)>=0){D.from.x+=i.x;D.from.y+=i.y;G=true}if(L.id==null||z.indexOf(L.id)>=0){D.to.x+=i.x;D.to.y+=i.y;C=true}}if(G&&C){for(var w=0;w0){var I=Utils.getSelectedIds();Designer.painter.drawControls(I)}else{var E=$("#shape_controls");E.css({left:parseFloat(E.css("left"))+H.x,top:parseFloat(E.css("top"))+H.y})}var F=$("#shape_controls").position();if(F&&Utils.getSelected().length>0){Designer.op.showTip("X: "+Math.round(F.left.restoreScale())+"  Y: "+Math.round(F.top.restoreScale()))}function N(a){a.props.x+=i.x;a.props.y+=i.y;var b=$("#"+a.id);b.css({left:parseFloat(b.css("left"))+H.x,top:parseFloat(b.css("top"))+H.y})}},moveLinker:function(D,w,G,H){var K=null;var C=null;var z=Utils.getShapeByPosition(G,H,true);Designer.op.hideLinkPoint();if(z!=null){var L=z.shape;Utils.showAnchors(L);C=L.id;if(z.type=="bounding"){K=z.linkPoint;Designer.op.showLinkPoint(Utils.toScale(K))}else{if(z.type=="shape"){var u;var I;if(w=="from"){u={x:D.to.x,y:D.to.y};I=D.to.id}else{u={x:D.from.x,y:D.from.y};I=D.from.id}if(L.id==I){Designer.op.hideLinkPoint();K={x:G.restoreScale(),y:H.restoreScale()};K.angle=null;C=null}else{var B=L.getAnchors();var E=-1;var A;var t={x:L.props.x+L.props.w/2,y:L.props.y+L.props.h/2};for(var v=0;v=D.to.x-6&&K.x<=D.to.x+6){D.from.x=D.to.x}if(K.y>=D.to.y-6&&K.y<=D.to.y+6){D.from.y=D.to.y}}}else{D.to.x=K.x;D.to.y=K.y;D.to.id=C;D.to.angle=K.angle;if(C==null){if(K.x>=D.from.x-6&&K.x<=D.from.x+6){D.to.x=D.from.x}if(K.y>=D.from.y-6&&K.y<=D.from.y+6){D.to.y=D.from.y}}}Designer.painter.renderLinker(D,true)},showLinkPoint:function(e){var f=$("").appendTo($("#designer_canvas"));var d=f[0].getContext("2d");d.translate(1,1);d.lineWidth=1;d.globalAlpha=0.3;d.strokeStyle=Designer.config.anchorColor;d.fillStyle=Designer.config.anchorColor;d.beginPath();d.moveTo(0,15);d.bezierCurveTo(0,-5,30,-5,30,15);d.bezierCurveTo(30,35,0,35,0,15);d.closePath();d.fill();d.stroke();f.css({left:e.x-16,top:e.y-16,"z-index":Model.orderList.length}).show()},hideLinkPoint:function(){$(".link_point_canvas").hide()},brokenLinkerChangable:function(k,l){var h=$("#canvas_container");var g=$("#designer_canvas");var i=k.points[l-1];var j=k.points[l];if(i.x==j.x){h.css("cursor","e-resize")}else{h.css("cursor","n-resize")}g.bind("mousedown.brokenLinker",function(a){Designer.op.changeState("changing_broken_linker");var b=Utils.getRelativePos(a.pageX,a.pageY,g);var c=Utils.getSelectedIds();h.bind("mousemove.brokenLinker",function(e){var f=Utils.getRelativePos(e.pageX,e.pageY,g);var d={x:f.x-b.x,y:f.y-b.y};d=Utils.restoreScale(d);if(i.x==j.x){i.x+=d.x;j.x+=d.x}else{i.y+=d.y;j.y+=d.y}Designer.painter.renderLinker(k);if(c.length>1){Designer.painter.drawControls(c)}b=f;$(document).unbind("mouseup.changed").bind("mouseup.changed",function(){Model.update(k);$(document).unbind("mouseup.changed")})});$(document).bind("mouseup.brokenLinker",function(){Designer.op.resetState();h.unbind("mousemove.brokenLinker");g.unbind("mousedown.brokenLinker");$(document).unbind("mouseup.brokenLinker")})})},removeShape:function(){var d=Utils.getSelected();if(d.length>0){Utils.unselect();var e=Utils.getAttachedShapes(d);d=d.concat(e);var c=[];for(var b=0;b0){var shapeIds=[];for(var index=0;index0){$.ajax({url:"./jd?sid="+$("#sid").val()+"&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_relation_search",data:{shapeIds:shapeIds.join(","),fileId:ruuid},success:function(msg){if(typeof(msg)=="string"){msg=eval("("+msg+")")}var relationShapes=msg.data.relationShapes;if(relationShapes.length>0){var options={title:"提示",content:"图形["+relationShapes+"]被关联,确定删除吗?",onConfirm:function(){Model.remove(d)}};$.confirm(options)}else{Model.remove(d)}}})}else{Model.remove(d)}}}},showTip:function(h){var f=$("#designer_op_tip");if(f.length==0){f=$("
    ").appendTo("#designer_canvas")}f.stop().html(h);var e=$("#shape_controls");var g=e.position();f.css({top:g.top+e.height()+5,left:g.left+e.width()/2-f.outerWidth()/2,"z-index":Model.orderList.length}).show()},hideTip:function(){$("#designer_op_tip").fadeOut(100)},snapLine:function(R,Q,S,ae){var U=R.y;var J=R.y+R.h/2;var ad=R.y+R.h;var af=R.x;var T=R.x+R.w/2;var X=R.x+R.w;var ag=2;var ab={v:null,h:null,attach:null};var W=null;if(S){W=ae}else{W=Model.getShapeById(Q[0])}if(Q.length==1&&W.groupName=="boundaryEvent"){for(var K=Model.orderList.length-1;K>=0;K--){var P=Model.orderList[K].id;var ai=Model.getShapeById(P);if(ai.name!="linker"&&ai.id!=W.id){var O=ai.props;if(ab.attach==null&&O.angle==0&&(ai.groupName=="task"||ai.groupName=="callActivity"||ai.groupName=="subProcess")){var p={x:O.x-ag,y:O.y-ag,w:O.w+ag*2,h:O.h+ag*2};if(Utils.pointInRect(T,J,p)){var aj=O.y;var ac=O.y+O.h;var M=O.x;var L=O.x+O.w;var V=false;var aa=false;if(aj>=J-ag&&aj<=J+ag){R.y=aj-R.h/2;aa=true}else{if(ac>=J-ag&&ac<=J+ag){R.y=ac-R.h/2;aa=true}}if(M>=T-ag&&M<=T+ag){R.x=M-R.w/2;V=true}else{if(L>=T-ag&&L<=T+ag){R.x=L-R.w/2;V=true}}if(V||aa){ab.attach=ai}}}}}}if(ab.attach==null){for(var K=Model.orderList.length-1;K>=0;K--){var P=Model.orderList[K].id;var ai=Model.getShapeById(P);if(ai.name=="linker"||Q.indexOf(P)>=0||ai.parent){continue}var O=ai.props;if(ab.h==null){var aj=O.y;var ak=O.y+O.h/2;var ac=O.y+O.h;if(ak>=J-ag&&ak<=J+ag){ab.h={type:"middle",y:ak};R.y=ak-R.h/2}else{if(aj>=U-ag&&aj<=U+ag){ab.h={type:"top",y:aj};R.y=aj}else{if(ac>=ad-ag&&ac<=ad+ag){ab.h={type:"bottom",y:ac};R.y=ac-R.h}else{if(ac>=U-ag&&ac<=U+ag){ab.h={type:"top",y:ac};R.y=ac}else{if(aj>=ad-ag&&aj<=ad+ag){ab.h={type:"bottom",y:aj};R.y=aj-R.h}}}}}}if(ab.v==null){var M=O.x;var N=O.x+O.w/2;var L=O.x+O.w;if(N>=T-ag&&N<=T+ag){ab.v={type:"center",x:N};R.x=N-R.w/2}else{if(M>=af-ag&&M<=af+ag){ab.v={type:"left",x:M};R.x=M}else{if(L>=X-ag&&L<=X+ag){ab.v={type:"right",x:L};R.x=L-R.w}else{if(L>=af-ag&&L<=af+ag){ab.v={type:"left",x:L};R.x=L}else{if(M>=X-ag&&M<=X+ag){ab.v={type:"right",x:M};R.x=M-R.w}}}}}}if(ab.h!=null&&ab.v!=null){break}}}this.hideSnapLine();var ah=$("#designer_canvas");if(ab.attach!=null){var Y=$("#designer_op_snapline_attach");if(Y.length==0){Y=$("
    ").appendTo(ah)}var I=ab.attach;var al=I.lineStyle.lineWidth;Y.css({width:(I.props.w+al).toScale(),height:(I.props.h+al).toScale(),left:(I.props.x-al/2).toScale()-2,top:(I.props.y-al/2).toScale()-2,"z-index":$("#"+I.id).css("z-index")}).show()}if(ab.h!=null){var i=$("#designer_op_snapline_h");if(i.length==0){i=$("
    ").appendTo(ah)}i.css({width:ah.width()+Designer.config.pageMargin*2,left:-Designer.config.pageMargin,top:Math.round(ab.h.y.toScale()),"z-index":Model.orderList.length+1}).show()}if(ab.v!=null){var Z=$("#designer_op_snapline_v");if(Z.length==0){Z=$("
    ").appendTo(ah)}Z.css({height:ah.height()+Designer.config.pageMargin*2,top:-Designer.config.pageMargin,left:Math.round(ab.v.x.toScale()),"z-index":Model.orderList.length+1}).show()}return ab},snapResizeLine:function(K,I,J){var L=K.y;var i=K.y+K.h/2;var P=K.y+K.h;var Q=K.x;var C=K.x+K.w/2;var D=K.x+K.w;var R=2;var N={v:null,h:null};for(var F=Model.orderList.length-1;F>=0;F--){var B=Model.orderList[F].id;var U=Model.getShapeById(B);if(U.name=="linker"||I.indexOf(B)>=0||U.parent){continue}var H=U.props;if(N.h==null&&(J.indexOf("t")>=0||J.indexOf("b")>=0)){var T=H.y;var V=H.y+H.h/2;var O=H.y+H.h;if(V>=i-R&&V<=i+R){N.h={type:"middle",y:V};if(J.indexOf("t")>=0){K.h=(P-V)*2;K.y=P-K.h}else{K.h=(V-K.y)*2}}else{if(J.indexOf("t")>=0&&T>=L-R&&T<=L+R){N.h={type:"top",y:T};K.y=T;K.h=P-T}else{if(J.indexOf("b")>=0&&O>=P-R&&O<=P+R){N.h={type:"bottom",y:O};K.h=O-L}else{if(J.indexOf("t")>=0&&O>=L-R&&O<=L+R){N.h={type:"top",y:O};K.y=O;K.h=P-O}else{if(J.indexOf("b")>=0&&T>=P-R&&T<=P+R){N.h={type:"bottom",y:T};K.h=T-K.y}}}}}}if(N.v==null&&(J.indexOf("l")>=0||J.indexOf("r")>=0)){var p=H.x;var A=H.x+H.w/2;var G=H.x+H.w;if(A>=C-R&&A<=C+R){N.v={type:"center",x:A};if(J.indexOf("l")>=0){K.w=(D-A)*2;K.x=D-K.w}else{K.w=(A-K.x)*2}}else{if(J.indexOf("l")>=0&&p>=Q-R&&p<=Q+R){N.v={type:"left",x:p};K.x=p;K.w=D-p}else{if(J.indexOf("r")>=0&&G>=D-R&&G<=D+R){N.v={type:"right",x:G};K.w=G-K.x}else{if(J.indexOf("l")>=0&&G>=Q-R&&G<=Q+R){N.v={type:"left",x:G};K.x=G;K.w=D-G}else{if(J.indexOf("r")>=0&&p>=D-R&&p<=D+R){N.v={type:"right",x:p};K.w=p-K.x}}}}}}if(N.h!=null&&N.v!=null){break}}this.hideSnapLine();var S=$("#designer_canvas");if(N.h!=null){var E=$("#designer_op_snapline_h");if(E.length==0){E=$("
    ").appendTo(S)}E.css({width:S.width()+Designer.config.pageMargin*2,left:-Designer.config.pageMargin,top:Math.round(N.h.y.toScale()),"z-index":Model.orderList.length+1}).show()}if(N.v!=null){var M=$("#designer_op_snapline_v");if(M.length==0){M=$("
    ").appendTo(S)}M.css({height:S.height()+Designer.config.pageMargin*2,top:-Designer.config.pageMargin,left:Math.round(N.v.x.toScale()),"z-index":Model.orderList.length+1}).show()}return N},hideSnapLine:function(){$("#designer_op_snapline_h").hide();$("#designer_op_snapline_v").hide();$("#designer_op_snapline_attach").hide()},linkDashboard:function(q){var m=Model.getShapeById(q.from.id);var t=m.category;if($("#panel_"+t).length!=0){var p=$("#shape_dashboard_"+t);if(p.length==0){p=$("").appendTo("#designer_canvas");function r(b,d){var e="
    ";var c=$(e).appendTo(p);if(d){c.append("")}var a=c.children()[0];Designer.painter.drawPanelItem(a,b.name)}for(var l in Schema.shapes){var o=Schema.shapes[l];if((o.category=="process_bpmn2"||o.category=="process.bpmn2"||o.category=="bpmn")&&checkRunningTimeShape(o)){continue}if(o.category==t){var s=o.attribute;if(s.visible&&s.linkable){if(!o.groupName){r(o)}else{var k=SchemaGroup.getGroup(o.groupName);if(k[0]==o.name){r(o,o.groupName)}}}}}p.bind("mousemove",function(a){a.stopPropagation()}).bind("mousedown",function(a){a.stopPropagation()})}p.css({left:q.to.x.toScale(),top:q.to.y.toScale(),"z-index":Model.orderList.length}).show();p.find(".link_shape_icon").unbind().bind("mousedown",function(f){f.stopPropagation();var a=$(this).attr("group");var d=$(this).parent().position();var e=p.position();var b=d.left+e.left+$(this).parent().outerWidth()-10;var c=d.top+e.top+$(this).parent().outerHeight();Designer.op.groupDashboard(a,b,c,function(g){n(g);p.hide();$(document).unbind("mousedown.dashboard")})}).bind("click",function(a){a.stopPropagation()});p.children(".dashboard_box").unbind().bind("click",function(){p.hide();$(document).unbind("mousedown.dashboard");var a=$(this);var b=a.attr("shapeName");n(b)});initRunningDashboard(p);$(document).bind("mousedown.dashboard",function(){p.hide();$(document).unbind("mousedown.dashboard")});function n(e){var y=Schema.shapes[e];var d=Utils.getEndpointAngle(q,"to");var b=Utils.getAngleDir(d);var f=y.getAnchors();var A;if(b==1){var c=null;for(var j=0;jg){g=z.x;A=z}}}else{if(b==3){var h=null;for(var j=0;jh){h=z.y;A=z}}}else{if(b==4){var B=null;for(var j=0;j").appendTo("#designer_canvas");var i=SchemaGroup.getGroup(m);for(var r=0;r").appendTo(o);var u=q.children("canvas")[0];Designer.painter.drawPanelItem(u,p.name)}}o.bind("mousedown",function(a){a.stopPropagation()})}o.css({left:s,top:n,"z-index":Model.orderList.length+1}).show();$(".dashboard_box").unbind().bind("click",function(){var a=$(this).attr("shapeName");t(a);o.hide();$(document).unbind("mousedown.group_dashboard")});$(document).bind("mousedown.group_dashboard",function(){o.hide();$(document).unbind("mousedown.group_dashboard")});return o},showPanelGroup:function(o,z,t){z.stopPropagation();var s=$("#group_dashboard_"+o);$(".group_dashboard").hide();if(s.length==0){s=$("").appendTo("#designer");var i=SchemaGroup.getGroup(o);for(var v=0;v").appendTo(s);var x=u.children("canvas")[0];Designer.painter.drawPanelItem(x,r.name)}}s.css("position","fixed")}var p=$(t).parent();var w=p.offset();s.show();var q=w.top+p.height();if(q+s.outerHeight()>$(window).height()){q=$(window).height()-s.outerHeight()}s.css({left:w.left-7,top:q});$(document).bind("mousedown.group_board",function(){s.hide();$(document).unbind("mousedown.group_board")})},changeShapeProps:function(j,o){function p(e){if(typeof o.x!="undefined"){e.x+=(o.x-j.props.x)}if(typeof o.y!="undefined"){e.y+=(o.y-j.props.y)}if(typeof o.w!="undefined"||typeof o.h!="undefined"||typeof o.angle!="undefined"){var f=$.extend({},j.props,o);var g={x:j.props.x+j.props.w/2,y:j.props.y+j.props.h/2};var b=Utils.getRotated(g,e,-j.props.angle);var c=j.props.w;var h=j.props.h;if(typeof o.w!="undefined"){e.x=j.props.x+(b.x-j.props.x)/j.props.w*o.w;c=o.w}else{e.x=b.x}if(typeof o.h!="undefined"){e.y=j.props.y+(b.y-j.props.y)/j.props.h*o.h;h=o.h}else{e.y=b.y}var d={x:j.props.x+c/2,y:j.props.y+h/2};var a=Utils.getRotated(d,e,f.angle);e.x=a.x;e.y=a.y}if(typeof o.angle!="undefined"){e.angle+=o.angle-j.props.angle}}var m=[];var l=Model.getShapeLinkers(j.id);if(l&&l.length>0){for(var i=0;i").appendTo("#designer_viewport")}j.html("选择目标图形并使用格式刷样式
    Esc取消").show();$(document).unbind("keydown.cancelbrush").bind("keydown.cancelbrush",function(a){if(a.keyCode==27){$("#bar_brush").button("unselect");j.hide();$(document).unbind("keydown.cancelbrush");Utils.selectCallback=null;$("#bar_brush").button("disable")}});Utils.selectCallback=function(){var b=Utils.getSelected();for(var a=0;a1){k=1}var i={x:(1-k)*c.x+k*d.x,y:(1-k)*c.y+k*d.y};var a=Utils.measureDistance(j,i);if(a>=f[e]||k>=1){if(g){this.lineTo(i.x,i.y)}else{this.moveTo(i.x,i.y)}g=!g;j=i;e++;if(e>=f.length){e=0}}}this.moveTo(d.x,d.y)}else{this.lineTo(d.x,d.y)}this.prePoint=d;if(this.beginPoint==null){this.beginPoint=d}},curve:function(e){if(typeof this.webkitLineDash!="undefined"&&typeof this.lineDashOffset=="undefined"&&this.lineWidth!=0){var g=this.webkitLineDash;var d=this.prePoint;var i=Utils.measureDistance(d,e);var n=0;var b=1/i;var l=d;var f=0;var h=true;var c=0;while(n<1){n+=b;if(n>1){n=1}var k={x:d.x*Math.pow((1-n),3)+e.x1*n*Math.pow((1-n),2)*3+e.x2*Math.pow(n,2)*(1-n)*3+e.x*Math.pow(n,3),y:d.y*Math.pow((1-n),3)+e.y1*n*Math.pow((1-n),2)*3+e.y2*Math.pow(n,2)*(1-n)*3+e.y*Math.pow(n,3)};var a=Utils.measureDistance(l,k);if(a>=g[f]||n>=1){if(h){var m=c+(n-c)/2;var j={x:d.x*Math.pow((1-m),3)+e.x1*m*Math.pow((1-m),2)*3+e.x2*Math.pow(m,2)*(1-m)*3+e.x*Math.pow(m,3),y:d.y*Math.pow((1-m),3)+e.y1*m*Math.pow((1-m),2)*3+e.y2*Math.pow(m,2)*(1-m)*3+e.y*Math.pow(m,3)};this.lineTo(j.x,j.y);this.lineTo(k.x,k.y)}else{this.moveTo(k.x,k.y)}h=!h;l=k;c=n;f++;if(f>=g.length){f=0}}}this.moveTo(e.x,e.y)}else{this.bezierCurveTo(e.x1,e.y1,e.x2,e.y2,e.x,e.y)}this.prePoint=e;if(this.beginPoint==null){this.beginPoint=e}},quadraticCurve:function(e){if(typeof this.webkitLineDash!="undefined"&&typeof this.lineDashOffset=="undefined"&&this.lineWidth!=0){var g=this.webkitLineDash;var d=this.prePoint;var i=Utils.measureDistance(d,e);var n=0;var b=1/i;var l=d;var f=0;var h=true;var c=0;while(n<1){n+=b;if(n>1){n=1}var k={x:d.x*Math.pow((1-n),2)+e.x1*n*(1-n)*2+e.x*Math.pow(n,2),y:d.y*Math.pow((1-n),2)+e.y1*n*(1-n)*2+e.y*Math.pow(n,2)};var a=Utils.measureDistance(l,k);if(a>=g[f]||n>=1){if(h){var m=c+(n-c)/2;var j={x:d.x*Math.pow((1-m),2)+e.x1*m*(1-m)*2+e.x*Math.pow(m,2),y:d.y*Math.pow((1-m),2)+e.y1*m*(1-m)*2+e.y*Math.pow(m,2)};this.lineTo(j.x,j.y);this.lineTo(k.x,k.y)}else{this.moveTo(k.x,k.y)}h=!h;l=k;c=n;f++;if(f>=g.length){f=0}}}this.moveTo(e.x,e.y)}else{this.quadraticCurveTo(e.x1,e.y1,e.x,e.y)}this.prePoint=e;if(this.beginPoint==null){this.beginPoint=e}},close:function(){if(typeof this.webkitLineDash!="undefined"&&typeof this.lineDashOffset=="undefined"&&this.lineWidth!=0){var f=this.webkitLineDash;var c=this.prePoint;var d=this.beginPoint;var h=Utils.measureDistance(c,d);var k=0;var b=1/h;var j=c;var e=0;var g=true;while(k<1){k+=b;if(k>1){k=1}var i={x:(1-k)*c.x+k*d.x,y:(1-k)*c.y+k*d.y};var a=Utils.measureDistance(j,i);if(a>=f[e]||k>=1){if(g){this.lineTo(i.x,i.y)}else{this.moveTo(i.x,i.y)}g=!g;j=i;e++;if(e>=f.length){e=0}}}}this.closePath()}},setLineDash:function(d,c){if(!d.setLineDash){d.setLineDash=function(){}}d.setLineDash(c);d.mozDash=c;d.webkitLineDash=c},renderShapePath:function(f,e,h){var g;if(h&&e.drawIcon){g=e.drawIcon(e.props.w,e.props.h)}else{g=e.getPath()}this.renderPath(f,e,g,h)},renderPath:function(m,o,i,t){for(var q=0;q=Designer.config.panelItemWidth||l.h>=Designer.config.panelItemWidth){if(h.props.w>=h.props.h){l.w=Designer.config.panelItemWidth-h.lineStyle.lineWidth*2;l.h=parseInt(h.props.h/h.props.w*l.w)}else{l.h=Designer.config.panelItemHeight-h.lineStyle.lineWidth*2;l.w=parseInt(h.props.w/h.props.h*l.h)}}h.props=l;i.save();i.lineJoin="round";i.globalAlpha=h.shapeStyle.alpha;var j=(Designer.config.panelItemWidth-l.w)/2;var k=(Designer.config.panelItemHeight-l.h)/2;i.translate(j,k);i.translate(l.w/2,l.h/2);i.rotate(l.angle);i.translate(-(l.w/2),-(l.h/2));this.renderShapePath(i,h,true,function(){Designer.painter.drawPanelItem(n,m)});this.renderMarkers(i,h,true);i.restore()},handleShapeConfigData:function(dataArray,q,attributesJsonArray){var temp1;for(var i=q.dataAttributes.length-1;i>=0;i--){temp1=q.dataAttributes[i];var hor=temp1.horizontal;var ver=temp1.vertical;if(temp1.hasOwnProperty("attributesJsonArray")){var temp2=temp1.dataShowConfig;if(temp2!=undefined){temp2.value=[]}break}}var key=q.name;for(var i=0;i0){for(var j=0;j=0&&(cfgContent+'').trim().length>0){cfgContent="("+temp.attrName+")"+cfgContent}if(attrType=="relation"&&cfgContent.length==0){cfgContent=""}else if(attrType=="relation"&&cfgContent.length>0){var shapeIdAttrId=q.id+"_"+attrId;var relationData=relationShapeModelObject;var relationValue="";for(var j=0;j0){for(i=0;i=0)){tempCommonShapeConfig.push(commonShapeConfig[i])}}}}if(tempCommonShapeConfig.length>0){dataArray=specialShapeConfig.concat(tempCommonShapeConfig)}else{dataArray=specialShapeConfig}this.handleShapeConfigData(dataArray,q,attributesJsonArray)}}var o=$("#"+q.id);if(o.length==0){var v=$("#designer_canvas");o=$("
    ").appendTo(v)}var t=Utils.getShapeBox(q);var w=(t.w+20).toScale();var s=(t.h+20).toScale();o.find(".shape_canvas").attr({width:w,height:s});o.css({left:(t.x-10).toScale()+"px",top:(t.y-10).toScale()+"px",width:w,height:s});var n=o.find(".shape_canvas")[0].getContext("2d");n.clearRect(0,0,q.props.w+20,q.props.h+20);n.scale(Designer.config.scale,Designer.config.scale);n.translate(10,10);n.translate(q.props.x-t.x,q.props.y-t.y);n.translate(q.props.w/2,q.props.h/2);n.rotate(q.props.angle);n.translate(-(q.props.w/2),-(q.props.h/2));var x=q.lineStyle;n.globalAlpha=q.shapeStyle.alpha;n.lineJoin="round";this.renderShapePath(n,q);this.renderMarkers(n,q);var m=q.getPath();var p=Utils.copy(m[m.length-1]);p.fillStyle={type:"none"};p.lineStyle={lineWidth:0};var u=[p];this.renderPath(n,q,u);this.renderText(q,t);this.renderDataAttributes(q,t);Designer.painter.renderShapeLink(o,q);Designer.painter.renderSahpeAttachment(o,q);if(q.attributesJsonArray!=undefined&&q.attributesJsonArray.length>0){o.find(".shape_danger").remove();o.find(".shape_regulate").remove();var A=false;var z=false;for(var r in q.attributesJsonArray){var l=q.attributesJsonArray[r];if(l!=undefined&&l.key=="danger"&&l.value!=undefined&&l.value!=""&&relationShapesObject!=undefined){if(typeof l.value=='object'&&l.value.constructor==Array){for(var m=0;m").appendTo(o)}}},fillShape:function(n,i,h){i.save();if(h.type=="solid"){i.fillStyle="rgb("+h.color+")";i.fill()}else{if(h.type=="gradient"){var j;if(h.gradientType=="linear"){j=GradientHelper.createLinearGradient(n,i,h)}else{j=GradientHelper.createRadialGradient(n,i,h)}i.fillStyle=j;i.fill()}else{if(h.type=="image"){var m=h.fileId;var k=$(".shape_img[src='"+m+"']");if(k.length==0){k=$("").appendTo("#shape_img_container");k.bind("load.drawshape",function(){var b=(Designer.config.panelItemWidth-n.props.w)/2;var a=(Designer.config.panelItemHeight-n.props.h)/2;i.translate(b,a);l(k);i.restore();$(this).attr("loaded","1")});k.attr("src",m)}else{if(k.attr("loaded")=="0"){k.bind("load.drawshape",function(){var b=0;var a=0;i.translate(b,a);l(k);i.restore()})}else{l(k)}}}}}i.restore();function l(r){i.save();i.clip();if(h.display=="fit"){var d=r.width();var q=r.height();var a=d/q;var e=n.props.w/n.props.h;if(a>e){var g=n.props.w;var b=0;var s=g/a;var c=n.props.h/2-s/2;i.drawImage(r[0],b,c,g,s)}else{var s=n.props.h;var c=0;var g=s*a;var b=n.props.w/2-g/2;i.drawImage(r[0],b,c,g,s)}}else{if(h.display=="stretch"){i.drawImage(r[0],0,0,n.props.w,n.props.h)}else{if(h.display=="original"){var d=r.width();var q=r.height();var b=n.props.w/2-d/2;var c=n.props.h/2-q/2;i.drawImage(r[0],b,c,d,q)}else{if(h.display=="tile"){var b=0;var d=r.width();var q=r.height();while(be){var s=n.props.h;var c=0;var g=s*a;var b=n.props.w/2-g/2;i.drawImage(r[0],b,c,g,s)}else{var g=n.props.w;var b=0;var s=g/a;var c=n.props.h/2-s/2;i.drawImage(r[0],b,c,g,s)}}}}}}}i.restore()}},renderText:function(z,r){var B=$("#"+z.id);var v=B.find(".text_canvas[forshape="+z.id+"]");if(v.length==0){v=$("").appendTo(B);v.bind("focus",function(){$(this).blur()})}v.attr("readonly","readonly");if(z.text==null||z.text.trim()==""){v.css({height:"0px",width:"0px"}).hide();return}var C=z.fontStyle;var G={"line-height":Math.round(C.size*1.25)+"px","font-size":C.size+"px","font-family":C.fontFamily,"font-weight":C.bold?"bold":"normal","font-style":C.italic?"italic":"normal","text-align":C.textAlign,color:"rgb("+C.color+")","text-decoration":C.underline?"underline":"none",opacity:z.shapeStyle.alpha};v.css(G);v.show();var s=z.getTextBlock();if(z.fontStyle.orientation=="horizontal"){var D={x:s.x+s.w/2,y:s.y+s.h/2};s={x:D.x-s.h/2,y:D.y-s.w/2,w:s.h,h:s.w}}v.css({width:s.w});v.height(0);v.val(z.text);v.scrollTop(99999);var E=v.scrollTop();var y=0;if(C.vAlign=="middle"){y=(s.y+s.h/2-E/2)}else{if(z.fontStyle.vAlign=="bottom"){y=(s.y+s.h-E)}else{y=s.y}}var t={x:s.x+s.w/2,y:y+E/2};var w=z.props.angle;if(w!=0){var H={x:z.props.w/2,y:z.props.h/2};t=Utils.getRotated(H,t,w)}if(C.orientation=="horizontal"){w=(Math.PI*1.5+w)%(Math.PI*2)}var F=Math.round(w/(Math.PI*2)*360);var x="rotate("+F+"deg) scale("+Designer.config.scale+")";var A=s.w;var u=E;v.css({width:A,height:u,left:(t.x+(z.props.x-r.x)+10).toScale()-s.w/2,top:(t.y+(z.props.y-r.y)+10).toScale()-E/2,"-webkit-transform":x,"-ms-transform":x,"-o-transform":x,"-moz-transform":x,transform:x})},calculateTextLines:function(D,i,z){var E=i.w;var w=i.h;var J=[];var H=D.split(/\n/);for(var x=0;xE){for(var I=0;IE){J.push(F);F=j[I]}else{F=p}}}else{var p=F+j;var G=z.measureText(p).width;if(G>E){J.push(F);F=j}else{F=p}}}if(F!=""){J.push(F)}}}return J},renderMarkers:function(n,r,v){if(r.attribute&&r.attribute.markers&&r.attribute.markers.length>0){var u=r.attribute.markers;var i=Schema.config.markerSize;var q=4;if(v){i=10}var t=r.attribute.markerOffset;if(v){t=5}var w=u.length*i+(u.length-1)*q;var p=r.props.w/2-w/2;for(var s=0;s0){for(var n=0;n").appendTo($("#"+i.id));var b=H[0].getContext("2d");var w="12px ";w+=i.fontStyle.fontFamily;b.font=w;var D=b.measureText(y).width;var a=20;if(x!=""){D+=20}var E,F;if(h=="mostleft"){E=-D-2}else{if(h=="leftedge"){E=-D/2}else{if(h=="left"){E=2}else{if(h=="center"){E=(i.props.w-D)/2}else{if(h=="right"){E=i.props.w-D-2;if(h=="rightedge"){E=i.props.w-D/2}else{E=i.props.w+2}}}}}}if(I=="mosttop"){F=-a}else{if(I=="topedge"){F=-a/2}else{if(I=="top"){F=0}else{if(I=="middle"){F=(i.props.h-a)/2}else{if(I=="bottom"){F=i.props.h-a}else{if(I=="bottomedge"){F=i.props.h-a/2}else{F=i.props.h}}}}}}var g={x:E,y:F,w:D,h:a};var G=Utils.getRotatedBox(g,i.props.angle,n);H.attr({width:G.w.toScale(),height:G.h.toScale()});b.font=w;var d=(G.x+(i.props.x-k.x)+10).toScale();var e=(G.y+(i.props.y-k.y)+10).toScale();if(h!="mostleft"||h=="left"||h!="right"){H.css({left:d,top:e})}b.scale(Designer.config.scale,Designer.config.scale);b.translate(G.w/2,G.h/2);b.rotate(i.props.angle);b.translate(-G.w/2,-G.h/2);b.translate((G.w-g.w)/2,(G.h-g.h)/2);b.globalAlpha=i.shapeStyle.alpha;if(c.type=="link"){b.fillStyle="#4183C4"}else{b.fillStyle="#333"}if(c.showType=="text"){b.fillStyle="#696969"}if(c.showType=="attr"){b.fillStyle="#191970"}b.textBaseline="middle";if(D>i.props.w){var tempShapeWidth=i.props.w;if(tempShapeWidth<100){tempShapeWidth=100}H[0].width=tempShapeWidth+10;H[0].height=Math.ceil(D/tempShapeWidth)*10+15;for(var v=0;v1){H.css({left:15,top:e})}if(h=="right"&&I!="mosttop"&&I!="bottom"){d=tempShapeWidth/4;H.css({left:d,top:e})}}else{if(h=="mostleft"){d=-D;H.css({left:d,top:e})}if(h=="right"){d=i.props.w-D;H.css({left:d,top:e})}b.fillText(y,0,a/2)}if(x!=""){if(x.indexOf("&#x")>=0){var icon=x.split("|")[0];var iconColor=x.split("|")[1];b.font="19px awsui-iconfont";icon=eval("('"+icon.replace('&#x','\\u').replace(';','')+"')");b.fillStyle=iconColor;b.fillText(icon,0,a/2);iconCavCode=H[0].toDataURL("image/png");c.iconCavCode=iconCavCode}else{var J="/images/data-attr/"+x+".png";var f=$(".shape_img[src='"+J+"']");if(f.length==0){f=$("").appendTo("#shape_img_container")}if(f.attr("loaded")=="true"){b.drawImage(f[0],g.w-20,0,20,20)}else{f.bind("load.drawshape",function(){$(this).attr("loaded","true");b.drawImage(f[0],g.w-20,0,20,20)})}}}b.beginPath();b.rect(0,0,D,a);b.closePath()}},renderLinker:function(h,k){if(k){h.points=Utils.getLinkerPoints(h)}if(h.linkerType=="curve"||h.linkerType=="broken"){if(!h.points||h.points.length==0){h.points=Utils.getLinkerPoints(h)}}var q=h.points;var o=Utils.copy(h.from);var a=Utils.copy(h.to);if(h.attribute&&h.attribute.collapseBy){$("#"+h.id).hide();return}else{$("#"+h.id).show()}var p=Utils.getEndpointAngle(h,"from");var d=Utils.getEndpointAngle(h,"to");var b=Utils.getLinkerLineStyle(h.lineStyle);l(o,h,b.beginArrowStyle,p);l(a,h,b.endArrowStyle,d);var B=a.x;var x=a.y;var y=o.x;var w=o.y;if(a.xy){y=n.x}}if(n.yw){w=n.y}}}var f={x:B,y:x,w:y-B,h:w-x};var C=$("#"+h.id);if(C.length==0){var g=$("#designer_canvas");C=$("
    ").appendTo(g)}if(!Model.getShapeById(h.id)){C.css("z-index",Model.orderList.length+1)}var A=C.find(".shape_canvas");A.attr({width:(f.w+20).toScale(),height:(f.h+20).toScale()});C.css({left:(f.x-10).toScale(),top:(f.y-10).toScale(),width:(f.w+20).toScale(),height:(f.h+20).toScale()});var m=A[0].getContext("2d");m.scale(Designer.config.scale,Designer.config.scale);m.translate(10,10);var s=Utils.getLinkerLineStyle(h.lineStyle);m.lineWidth=s.lineWidth;m.strokeStyle="rgb("+s.lineColor+")";m.fillStyle="rgb("+s.lineColor+")";m.save();var z={x:o.x-f.x,y:o.y-f.y};var c={x:a.x-f.x,y:a.y-f.y};m.save();if(s.lineStyle=="dashed"){this.setLineDash(m,[s.lineWidth*5,s.lineWidth*2])}else{if(s.lineStyle=="dot"){this.setLineDash(m,[s.lineWidth,s.lineWidth*1.5])}else{if(s.lineStyle=="dashdot"){this.setLineDash(m,[s.lineWidth*5,s.lineWidth*2,s.lineWidth,s.lineWidth*2])}}}m.lineJoin="round";m.beginPath();this.actions.move.call(m,z);if(h.linkerType=="curve"){var v=q[0];var u=q[1];var t={x1:v.x-f.x,y1:v.y-f.y,x2:u.x-f.x,y2:u.y-f.y,x:c.x,y:c.y};this.actions.curve.call(m,t)}else{for(var r=0;r").appendTo(m)}var n=l.fontStyle;var p="scale("+Designer.config.scale+")";var r={"line-height":Math.round(n.size*1.25)+"px","font-size":n.size+"px","font-family":n.fontFamily,"font-weight":n.bold?"bold":"normal","font-style":n.italic?"italic":"normal","text-align":n.textAlign,color:"rgb("+n.color+")","text-decoration":n.underline?"underline":"none","-webkit-transform":p,"-ms-transform":p,"-o-transform":p,"-moz-transform":p,transform:p};q.css(r);if(l.text==null||l.text==""){q.hide();return}q.show();var k=l.text.replace(//g,">").replace(/\n/g,"
    ");q.html(k+"
    ");var j=this.getLinkerMidpoint(l);var o=m.position();q.css({left:j.x.toScale()-o.left-q.width()/2,top:j.y.toScale()-o.top-q.height()/2})},getLinkerMidpoint:function(z){var w={};if(z.linkerType=="normal"){w={x:0.5*z.from.x+0.5*z.to.x,y:0.5*z.from.y+0.5*z.to.y}}else{if(z.linkerType=="curve"){var d=z.from;var q=z.points[0];var v=z.points[1];var x=z.to;w={x:d.x*0.125+q.x*0.375+v.x*0.375+x.x*0.125,y:d.y*0.125+q.y*0.375+v.y*0.375+x.y*0.125}}else{var u=[];u.push(z.from);u=u.concat(z.points);u.push(z.to);var r=0;for(var A=1;As){var p=(s-B)/y;w={x:(1-p)*q.x+p*v.x,y:(1-p)*q.y+p*v.y};break}B=t}}}return w},controlStatus:{resizeDir:[],rotatable:true},drawControls:function(m){var n=$("#shape_controls");if(n.length==0){var r=$("#designer_canvas");n=$("
    ").appendTo(r);n.append("");n.append("
    ");n.append("
    ");n.append("
    ");n.append("
    ");n.append("
    ");n.append("
    ");n.append("
    ");n.append("
    ");Designer.op.shapeResizable();n.append("");Designer.op.shapeRotatable();n.append("
    ");Designer.op.groupShapeChangable();$(".shape_controller").css({"border-color":Designer.config.anchorColor,width:Designer.config.anchorSize-2,height:Designer.config.anchorSize-2})}$(".shape_controller").css({"z-index":Model.orderList.length});$(".change_shape_icon").hide();n.show();var p=0;var i;var q;if(m.length==1){var l=Model.getShapeById(m[0]);i=l.props;p=l.props.angle;q=l.resizeDir;if(l.groupName&&SchemaGroup.groupExists(l.groupName)){$(".change_shape_icon").show()}}else{i=Utils.getControlBox(m);q=["tl","tr","br","bl"]}var t=true;for(var o=0;o1)){q=[]}}this.controlStatus.rotatable=t;this.controlStatus.resizeDir=q;this.rotateControls(i,p);return n},rotateControls:function(R,E){var O=$("#shape_controls");var N=Utils.getRotatedBox(R,E);var i=N.w.toScale();var Q=N.h.toScale();O.css({left:N.x.toScale(),top:N.y.toScale(),width:i,height:Q,"z-index":Model.orderList.length});var P=i+20;var K=Q+20;var S=$("#controls_bounding");S.attr({width:P,height:K});var J=S[0].getContext("2d");J.lineJoin="round";if(this.controlStatus.resizeDir.length==0){J.lineWidth=2;J.strokeStyle=Designer.config.selectorColor;J.globalAlpha=0.8}else{J.lineWidth=1;J.strokeStyle=Designer.config.selectorColor;J.globalAlpha=0.5}J.save();J.clearRect(0,0,P,K);J.translate(P/2,K/2);J.rotate(E);J.translate(-P/2,-K/2);J.translate(9.5,9.5);var W={x:Math.round((R.x-N.x).toScale()),y:Math.round((R.y-N.y).toScale()),w:Math.floor(R.w.toScale()+1),h:Math.floor(R.h.toScale()+1)};J.strokeRect(W.x,W.y,W.w,W.h);J.restore();var A=0-Designer.config.anchorSize/2;var G={};R=Utils.toScale(R);N=Utils.toScale(N);var D={x:(R.x+R.w/2),y:R.y+R.h/2};O.children(".shape_controller").hide();for(var H=0;H=0){U=R.x}else{if(L.indexOf("r")>=0){U=R.x+R.w}else{U=R.x+R.w/2}}if(L.indexOf("t")>=0){V=R.y}else{if(L.indexOf("b")>=0){V=R.y+R.h}else{V=R.y+R.h/2}}var T=Utils.getRotated(D,{x:U,y:V},E);X.css({left:T.x-N.x+A,top:T.y-N.y+A})}var M=Math.PI/8;O.children(".shape_controller").removeClass("s n e w");if(E>M&&E<=M*3){O.children("div[resizeDir=tl]").addClass("n");O.children("div[resizeDir=tr]").addClass("e");O.children("div[resizeDir=br]").addClass("s");O.children("div[resizeDir=bl]").addClass("w");O.children("div[resizeDir=l]").addClass("n w");O.children("div[resizeDir=r]").addClass("s e");O.children("div[resizeDir=b]").addClass("s w");O.children("div[resizeDir=t]").addClass("n e")}else{if(E>M*3&&E<=M*5){O.children("div[resizeDir=tl]").addClass("n e");O.children("div[resizeDir=tr]").addClass("s e");O.children("div[resizeDir=br]").addClass("s w");O.children("div[resizeDir=bl]").addClass("n w");O.children("div[resizeDir=l]").addClass("n");O.children("div[resizeDir=r]").addClass("s");O.children("div[resizeDir=b]").addClass("w");O.children("div[resizeDir=t]").addClass("e")}else{if(E>M*5&&E<=M*7){O.children("div[resizeDir=tl]").addClass("e");O.children("div[resizeDir=tr]").addClass("s");O.children("div[resizeDir=br]").addClass("w");O.children("div[resizeDir=bl]").addClass("n");O.children("div[resizeDir=l]").addClass("n e");O.children("div[resizeDir=r]").addClass("s w");O.children("div[resizeDir=b]").addClass("n w");O.children("div[resizeDir=t]").addClass("s e")}else{if(E>M*7&&E<=M*9){O.children("div[resizeDir=tl]").addClass("s e");O.children("div[resizeDir=tr]").addClass("s w");O.children("div[resizeDir=br]").addClass("n w");O.children("div[resizeDir=bl]").addClass("n e");O.children("div[resizeDir=l]").addClass("e");O.children("div[resizeDir=r]").addClass("w");O.children("div[resizeDir=b]").addClass("n");O.children("div[resizeDir=t]").addClass("s")}else{if(E>M*9&&E<=M*11){O.children("div[resizeDir=tl]").addClass("s");O.children("div[resizeDir=tr]").addClass("w");O.children("div[resizeDir=br]").addClass("n");O.children("div[resizeDir=bl]").addClass("e");O.children("div[resizeDir=l]").addClass("s e");O.children("div[resizeDir=r]").addClass("n w");O.children("div[resizeDir=b]").addClass("n e");O.children("div[resizeDir=t]").addClass("s w")}else{if(E>M*11&&E<=M*13){O.children("div[resizeDir=tl]").addClass("s w");O.children("div[resizeDir=tr]").addClass("n w");O.children("div[resizeDir=br]").addClass("n e");O.children("div[resizeDir=bl]").addClass("s e");O.children("div[resizeDir=l]").addClass("s");O.children("div[resizeDir=r]").addClass("n");O.children("div[resizeDir=b]").addClass("e");O.children("div[resizeDir=t]").addClass("w")}else{if(E>M*13&&E<=M*15){O.children("div[resizeDir=tl]").addClass("w");O.children("div[resizeDir=tr]").addClass("n");O.children("div[resizeDir=br]").addClass("e");O.children("div[resizeDir=bl]").addClass("s");O.children("div[resizeDir=l]").addClass("s w");O.children("div[resizeDir=r]").addClass("n e");O.children("div[resizeDir=b]").addClass("s e");O.children("div[resizeDir=t]").addClass("n w")}else{O.children("div[resizeDir=tl]").addClass("n w");O.children("div[resizeDir=tr]").addClass("n e");O.children("div[resizeDir=br]").addClass("s e");O.children("div[resizeDir=bl]").addClass("s w");O.children("div[resizeDir=l]").addClass("w");O.children("div[resizeDir=r]").addClass("e");O.children("div[resizeDir=b]").addClass("s");O.children("div[resizeDir=t]").addClass("n")}}}}}}}if(this.controlStatus.rotatable){var B=O.find(".shape_rotater");B.show();var C={x:R.x+R.w/2,y:R.y-20};var F=Utils.getRotated(D,C,E);B.css({top:F.y-20-N.y,left:F.x-20.5-N.x});var I=B[0].getContext("2d");I.lineWidth=1;I.strokeStyle=Designer.config.selectorColor;I.fillStyle="white";I.save();I.clearRect(0,0,41,40);I.translate(20.5,20);I.rotate(E);I.translate(-20.5,-20);I.beginPath();I.moveTo(20.5,20);I.lineTo(20.5,40);I.stroke();I.beginPath();I.arc(20.5,20,Designer.config.rotaterSize/2,0,Math.PI*2);I.closePath();I.fill();I.stroke();I.restore()}else{O.find(".shape_rotater").hide()}},renderShapeLink:function(o,q){o.find(".shape_link_point").remove();if(q.link){var y=$("").appendTo(o);y.on("mousedown.link",function(I){I.stopPropagation();var c=Model.getShapeById($(this).parent().attr("id"));myshapeLink=c;if(c!=undefined){var k=c.props.x;var j=c.props.y;var B=c.props.w;var H=c.props.h;var b=$("#link-dialog-normal_contextmenu");b.empty();var D=[];for(var G=0;G0&&window.opener){var a=parent.window.$("#appId").val();var K={sid:$("#sid").val(),cmd:"com.actionsoft.apps.coe.pal_pl_repository_designer_viewer_link_perm",uuids:d,filePerms:filePerms};if(window.opener){K.modelType="used"}else{if(a!=undefined&&a!="com.actionsoft.apps.coe.pal"&&a!=""){K.modelType="published"}}awsui.ajax.request({url:"./jd",method:"POST",data:K,async:false,ok:function(L){var N=[];var M=L.data.uuids;for(var e=0;e"+C.name+"";if(role=="owner"){F+='
    删除
    "}F+="";b.append(F)}}}var g=Utils.getShapeByPosition(k,j,false);var J=Designer.clipboard.elements.length;if(g==null){if(J>0){b.children("li[ac=paste]").show();b.children(".devi_clip").show()}}else{var c=g.shape;b.children("li[ac=cut]").show()}b.css({display:"block","z-index":Model.orderList.length+3,left:k+B+10,top:j+H});$(document).on("mousedown.link",":not(#link-dialog-normal_contextmenu li):not(#link-dialog-normal_contextmenu ul):not(#link-dialog-normal_contextmenu a):not(#link-dialog-normal_contextmenu div)",function(h){if(this.id=="link-dialog-normal_contextmenu"){return false}b.hide()})}I.stopPropagation()})}},renderSahpeAttachment:function(o,q){o.find(".shape_attachment_point").remove();var selflist=[];var relatelist=[];var reqComplete=false;var reqMethod_renderSahpeAttachment=function(isAsync){$.ajax({method:"POST",async:isAsync,url:"./jd?sid="+encodeURIComponent(sid)+"&cmd=com.actionsoft.apps.coe.pal_processlevel_upfile_load",data:{pl_uuid:ruuid,uuids:q.id},success:function(msg){selflist=msg.data.list;$.ajax({method:"POST",async:isAsync,url:"./jd?sid="+encodeURIComponent(sid)+"&cmd=com.actionsoft.apps.coe.pal_processlevel_relation_upfile_load",data:{pl_uuid:ruuid,shape_uuid:q.id},success:function(msg){relatelist=msg.data.list;reqComplete=true}})}})};reqMethod_renderSahpeAttachment(true);var startTime=new Date().getTime();var intervalClr=window.setInterval(function(){var endTime=new Date().getTime();if(endTime-startTime>5000||reqComplete==true){window.clearInterval(intervalClr);if((selflist&&selflist.length>0)||(relatelist&&relatelist.length>0)){var y=$("
    ").appendTo(o);y.on("mousedown.attachment",function(I){I.stopPropagation();reqMethod_renderSahpeAttachment(false);var c=Model.getShapeById($(this).parent().attr("id"));myshapeLink=c;if(c!=undefined){var k=c.props.x;var j=c.props.y;var B=c.props.w;var H=c.props.h;var b=$("#attachment-dialog-normal_contextmenu");b.empty();b.append('');for(var s=0;s<2;s++){var attalist=selflist;var attaTypeName="附件";if(s==0){}else{attalist=relatelist;attaTypeName="关联附件"}if(attalist.length>0){b.append('
  • '+attaTypeName+'
  • ');for(var f=0;f'+atta.fileName+'';if(downloadPerm){F+='
    下载
    '}F+="";b.append(F)}}}if(selflist.length==0&&relatelist.length==0){b.append('
  • 无附件
  • ')}var g=Utils.getShapeByPosition(k,j,false);var J=Designer.clipboard.elements.length;if(g==null){if(J>0){b.children("li[ac=paste]").show();b.children(".devi_clip").show()}}else{var c=g.shape;b.children("li[ac=cut]").show()}b.css({display:"block","z-index":Model.orderList.length+3,left:k+B+10,top:j+H});$(document).on("mousedown.attachment",":not(#attachment-dialog-normal_contextmenu span):not(#attachment-dialog-normal_contextmenu li):not(#attachment-dialog-normal_contextmenu ul):not(#attachment-dialog-normal_contextmenu a):not(#attachment-dialog-normal_contextmenu div)",function(h){if(this.id=="attachment-dialog-normal_contextmenu"){return false}b.hide()})}I.stopPropagation()})}}},100)},}};var Model={define:{},persistence:{},orderList:[],maxZIndex:0,linkerMap:{map:{},add:function(c,d){if(!this.map[c]){this.map[c]=[]}if(this.map[c].indexOf(d)<0){this.map[c].push(d)}},remove:function(c,d){if(this.map[c]){Utils.removeFromArray(this.map[c],d)}},empty:function(){this.map={}}},groupMap:{map:{},add:function(d,c){this.map[d]=c},push:function(d,c){if(!this.map[d]){this.map[d]=[]}this.map[d].push(c)},remove:function(b){delete this.map[b]},empty:function(){this.map={}}},create:function(l,h,j){var m=Utils.newId();var o=Utils.copy(Schema.shapes[l]);o.id=m;o.props.x=h;o.props.y=j;o.props.zindex=Model.maxZIndex+1;o.props=$.extend(true,{},Schema.shapeDefaults.props,o.props);for(var k=0;k0){for(var n in Model.define.localAttribute[o.name]){i.attributesJsonArray.push(Utils.copy(Model.define.localAttribute[o.name][n]))}}}}Designer.events.push("create",o);return o},add:function(d,c){this.addMulti([d],c)},addMulti:function(f,h){if(typeof h=="undefined"){h=true}var g=[];for(var i=0;i0){for(var x=0;x0){this.updateMulti(z)}MessageSource.commit();return true},updatePage:function(f,h){var e=$.extend(Model.define.page,f);var g={page:Utils.copy(Model.persistence.page),update:Utils.copy(e)};Model.persistence.page=Utils.copy(e);MessageSource.send("updatePage",g);Designer.initialize.initCanvas()},updateLocalAttribute:function(e){var c=$.extend(Model.define.localAttribute,e);var f={localAttribute:Utils.copy(Model.persistence.localAttribute),update:Utils.copy(c)};Model.persistence.localAttribute=Utils.copy(c);MessageSource.send("updateLocalAttribute",f)},getShapeById:function(b){return this.define.elements[b]},getPersistenceById:function(b){return this.persistence.elements[b]},build:function(){this.orderList=[];this.linkerMap.empty();for(var h in Model.define.elements){var g=Model.getShapeById(h);this.orderList.push({id:g.id,zindex:g.props.zindex});if(g.name=="linker"){if(g.from.id!=null){this.linkerMap.add(g.from.id,g.id)}if(g.to.id!=null){this.linkerMap.add(g.to.id,g.id)}}if(g.group){this.groupMap.push(g.group,g.id)}}this.orderList.sort(function i(a,b){return a.zindex-b.zindex});for(var j=0;j0){f=this.orderList[this.orderList.length-1].zindex}this.maxZIndex=f},getShapeLinkers:function(b){return this.linkerMap.map[b]},getGroupShapes:function(b){return this.groupMap.map[b]},changeShape:function(e,f){var d=Schema.shapes[f];e.name=f;e.title=d.shapeName;e.attribute=d.attribute;e.dataAttributes=d.dataAttributes;e.path=d.path;e.textBlock=d.textBlock;e.anchors=d.anchors;Schema.initShapeFunctions(e);Designer.painter.renderShape(e)}};var Utils={getDomById:function(b){return document.getElementById(b)},newId:function(){var c=Math.random();var d=(c+new Date().getTime());return d.toString(16).replace(".","")},getShapeByPosition:function(V,W,ab){var at=[];for(var x=Model.orderList.length-1;x>=0;x--){var S=Model.orderList[x].id;var i=$("#"+S);var am=Model.getShapeById(S);var ak=i.position();var ac=V-ak.left;var ad=W-ak.top;var R={x:ak.left,y:ak.top,w:i.width(),h:i.height()};var y=i.find(".shape_canvas")[0];var av=y.getContext("2d");var aB=this.pointInRect(V,W,R);if(am.name=="linker"){if(!aB){continue}if(ab){continue}var U=10;U=U.toScale();var ae={x:V-U,y:W-U,w:U*2,h:U*2};if(this.pointInRect(am.to.x.toScale(),am.to.y.toScale(),ae)){var al={type:"linker_point",point:"end",shape:am};at.push(al)}else{if(this.pointInRect(am.from.x.toScale(),am.from.y.toScale(),ae)){var al={type:"linker_point",point:"from",shape:am};at.push(al)}else{var aj=i.find(".text_canvas");var ah=aj.position();var ae={x:ah.left,y:ah.top,w:aj.width(),h:aj.height()};if(this.pointInRect(ac,ad,ae)){var al={type:"linker_text",shape:am};at.push(al);continue}U=7;U=U.toScale();var ag=this.pointInLinker({x:V.restoreScale(),y:W.restoreScale()},am,U);if(ag>-1){var al={type:"linker",shape:am,pointIndex:ag};at.push(al)}}}}else{if(aB&&am.locked&&!ab){if(av.isPointInPath(ac,ad)){var al={type:"shape",shape:am};at.push(al)}continue}var U=7;if(aB){U=U.toScale();var ae={x:V-U,y:W-U,w:U*2,h:U*2};var Z={x:am.props.x+am.props.w/2,y:am.props.y+am.props.h/2};var ao=am.getAnchors();var al=null;for(var aw=0;aw0){var ai=af.position();var X=ac-ai.left;var Y=ad-ai.top;var ar=af[0].getContext("2d");if(ar.isPointInPath(X,Y)){al={type:"dataAttribute",shape:am,attribute:ap};break}}}}if(al!=null){at.push(al);continue}}if(!aB){continue}if(av.isPointInPath(ac,ad)){if(ab){var ao=am.getAnchors();if(ao&&ao.length){var al={type:"shape",shape:am};at.push(al)}else{}}else{var al={type:"shape",shape:am};at.push(al)}}else{if(!am.attribute||typeof am.attribute.linkable=="undefined"||am.attribute.linkable){var an=Utils.getPointAngle(S,V.restoreScale(),W.restoreScale(),U);if(an!=null){var al=null;var aC={angle:an};for(var aa=1;aa<=U;aa++){if(an==0){aC.x=ac+aa;aC.y=ad}else{if(an1&&ab){al=at[0]}else{if(at.length>1){var ax=at[0];if(ax.type=="bounding"&&ax.type!="linker_point"&&ax.type!="linker"){return ax}var ag=[];var aA=[];var aq=[];for(var x=0;x0&&aA.length>0){for(var x=0;x0){aA.sort(function az(a,b){if(Utils.isSelected(a.shape.id)&&!Utils.isSelected(b.shape.id)){return-1}else{if(!Utils.isSelected(a.shape.id)&&Utils.isSelected(b.shape.id)){return 1}else{return b.shape.props.zindex-a.shape.props.zindex}}});al=aA[0]}if(al==null&&ag.length>0){ag.sort(function az(a,b){if(Utils.isSelected(a.shape.id)&&!Utils.isSelected(b.shape.id)){return-1}else{if(!Utils.isSelected(a.shape.id)&&Utils.isSelected(b.shape.id)){return 1}else{return b.shape.props.zindex-a.shape.props.zindex}}});al=ag[0]}if(al==null){al=at[0]}}}return al},checkCross:function(k,m,n,o){var j=false;var l=(m.x-k.x)*(o.y-n.y)-(m.y-k.y)*(o.x-n.x);if(l!=0){var p=((k.y-n.y)*(o.x-n.x)-(k.x-n.x)*(o.y-n.y))/l;var d=((k.y-n.y)*(m.x-k.x)-(k.x-n.x)*(m.y-k.y))/l;if((p>=0)&&(p<=1)&&(d>=0)&&(d<=1)){j=true}}return j},rectCross:function(m,n){var q=m.x;var o=m.x+m.w;var k=m.y;var s=m.y+m.h;var r=n.x;var p=n.x+n.w;var l=n.y;var t=n.y+n.h;if(((q=f.x&&d<=f.x+f.w&&e>=f.y&&e<=f.y+f.h){return true}return false},pointInLinker:function(q,t,s){var o=this.getLinkerLinePoints(t);var v={x:q.x-s,y:q.y};var w={x:q.x+s,y:q.y};var x={x:q.x,y:q.y-s};var m={x:q.x,y:q.y+s};for(var u=1;uj.x2){j.x2=m.x+m.w}if(j.y2==null||m.y+m.h>j.y2){j.y2=m.y+m.h}}var n={x:j.x1,y:j.y1,w:j.x2-j.x1,h:j.y2-j.y1};return n},getShapesBounding:function(h){var i={x1:null,y1:null,x2:null,y2:null};for(var l=0;li.x2){i.x2=k.x+k.w}if(i.y2==null||k.y+k.h>i.y2){i.y2=k.y+k.h}}var j={x:i.x1,y:i.y1,w:i.x2-i.x1,h:i.y2-i.y1};return j},getShapeContext:function(c){var d=Utils.getDomById(c);return d.getElementsByTagName("canvas")[0].getContext("2d")},selectIds:[],selectShape:function(s,w){if(typeof s=="string"){var o=s;s=[];s.push(o)}if(s.length<=0){return}var r=Utils.mergeArray([],s);for(var u=0;u0&&!i){var v=Designer.painter.drawControls(z)}if(typeof w=="undefined"){w=true}if(this.selectCallback&&w){this.selectCallback()}Designer.events.push("selectChanged");this.showLinkerCursor()},selectCallback:null,unselect:function(){var h=this.selectIds;this.selectIds=[];for(var e=0;e=0&&!this.isLocked(b)){return true}return false},isLocked:function(b){if(Model.getShapeById(b).locked){return true}else{return false}},linkerCursorTimer:null,showLinkerCursor:function(){this.hideLinkerCursor();var C=Utils.getSelectedIds();if(C.length==1){var J=Model.getShapeById(C[0]);if(J.name!="linker"){var H=Model.linkerMap.map[J.id];if(H&&H.length){var B=[];for(var z=0;z").appendTo("#designer_canvas");var m=j.linker;var i=(m.lineStyle.lineWidth+2).toScale();if(i<5){i=5}var n=i/2;j.half=n;j.dom=k;k.css({width:i,height:i,"-webkit-border-radius":n,"-moz-border-radius":n,"-ms-border-radius":n,"-o-border-radius":n,"border-radius":n,"z-index":$("#"+m.id).css("z-index")})}this.linkerCursorTimer=setInterval(function(){for(var w=0;w=c.maxT){c.t=0;c.dom.show()}var y=c.t;if(t.linkerType=="broken"){for(var v=1;v=b.t&&y=1){c.dom.hide()}}},30)},hideLinkerCursor:function(){if(this.linkerCursorTimer){clearInterval(this.linkerCursorTimer)}$(".linker_cursor").remove()},showLinkerControls:function(){this.hideLinkerControls();var e=Utils.getSelectedIds();var h=null;if(e.length==1){var f=Model.getShapeById(e[0]);if(f.name=="linker"&&f.linkerType=="curve"){h=f}}if(h==null){return}function g(r,s){var t=null;var b=null;if(s=="from"){t=r.from;b=r.points[0]}else{t=r.to;b=r.points[1]}var q=Utils.measureDistance(t,b).toScale()-6;var c={x:(0.5*t.x+0.5*b.x).toScale(),y:(0.5*t.y+0.5*b.y).toScale()};var u=Utils.getAngle(t,b)+Math.PI/2;var a=$("
    ").appendTo("#designer_canvas");var d=$("
    ").appendTo("#designer_canvas");var v=Math.round(u/(Math.PI*2)*360);var p="rotate("+v+"deg)";a.css({left:c.x,top:c.y-q/2,height:q,"z-index":Model.orderList.length,"-webkit-transform":p,"-ms-transform":p,"-o-transform":p,"-moz-transform":p,transform:p});d.css({left:b.x.toScale()-4,top:b.y.toScale()-4,"z-index":Model.orderList.length});d.attr("ty",s);d.unbind().bind("mousedown",function(j){r=Model.getShapeById(r.id);var i=null;if(s=="from"){i=r.points[0]}else{i=r.points[1]}j.stopPropagation();d.addClass("moving");Designer.op.changeState("changing_curve");$(document).bind("mousemove.change_curve",function(l){var k=Utils.getRelativePos(l.pageX,l.pageY,$("#designer_canvas"));i.x=k.x;i.y=k.y;Designer.painter.renderLinker(r);Model.define.elements[r.id]=r;Utils.showLinkerControls();$(".linker_control_point[ty="+d.attr("ty")+"]").addClass("moving");$(document).unbind("mouseup.changed_curve").bind("mouseup.changed_curve",function(m){Model.update(r);$(document).unbind("mouseup.changed_curve")})});$(document).unbind("mouseup.change_curve").bind("mouseup.change_curve",function(k){$(document).unbind("mouseup.change_curve");$(document).unbind("mousemove.change_curve");$(".linker_control_point").removeClass("moving");Designer.op.resetState()})});return d}g(h,"from");g(h,"to")},hideLinkerControls:function(){$(".linker_control_line").remove();$(".linker_control_point").remove()},showAnchors:function(n){if($(".shape_contour[forshape="+n.id+"]").length>0){return}var q=$("
    ").appendTo($("#designer_canvas"));q.css({left:n.props.x.toScale(),top:n.props.y.toScale(),"z-index":Model.orderList.length+1});if(!Utils.isSelected(n.id)){q.addClass("hovered_contour")}var t=Designer.config.anchorSize-2;var u={"border-color":Designer.config.anchorColor,"border-radius":Designer.config.anchorSize/2,width:t,height:t};var v=n.getAnchors();var o={x:n.props.w/2,y:n.props.h/2};var r=n.props.angle;for(var m=0;m").appendTo(q);var s=this.getRotated(o,p,r);u.left=s.x.toScale()-Designer.config.anchorSize/2;u.top=s.y.toScale()-Designer.config.anchorSize/2;l.css(u)}},hideAnchors:function(){$(".hovered_contour").remove()},removeAnchors:function(){$("#dock_btn_richtext").hide();$(".shape_contour").remove()},showLockers:function(s){var m=$("#"+s.id);var q=m.position();function t(){var c=$("").appendTo(m);var a=c[0].getContext("2d");a.strokeStyle="#777";a.lineWidth=1;var b=9;a.beginPath();a.moveTo(2,2);a.lineTo(b,b);a.moveTo(2,b);a.lineTo(b,2);a.stroke();return c}function r(b){var a=t();a.css({left:b.x.toScale()-q.left-5,top:b.y.toScale()-q.top-5})}if(s.name!="linker"){var u=s.props;var v={x:u.x+u.w/2,y:u.y+u.h/2};var l=this.getRotated(v,{x:u.x,y:u.y},s.props.angle);r(l);var n=this.getRotated(v,{x:u.x+u.w,y:u.y},s.props.angle);r(n);var o=this.getRotated(v,{x:u.x+u.w,y:u.y+u.h},s.props.angle);r(o);var p=this.getRotated(v,{x:u.x,y:u.y+u.h},s.props.angle);r(p)}else{r(s.from);r(s.to)}},removeLockers:function(){$(".shape_locker").remove()},measureDistance:function(g,h){var e=h.y-g.y;var f=h.x-g.x;return Math.sqrt(Math.pow(e,2)+Math.pow(f,2))},removeFromArray:function(f,d){var e=f.indexOf(d);if(e>=0){f.splice(e,1)}return f},addToArray:function(f,d){var e=f.indexOf(d);if(e<0){f.push(d)}return f},mergeArray:function(e,f){for(var h=0;h=d/4&&c=d/4*3&&c=d/4*5&&c=W.x-K&&V.x<=W.x+W.w+K){var P;if(V.xaa.y){X=y;V=aa;S=false}else{X=aa;V=y;S=true}var W=Model.getShapeById(X.id).props;var E=Model.getShapeById(V.id).props;if(V.x>=W.x-K&&V.x<=W.x+W.w+K){var Q=X.y+K;var P;if(V.xaa.x){X=y;V=aa;S=false}else{X=aa;V=y;S=true}var W=Model.getShapeById(X.id).props;var E=Model.getShapeById(V.id).props;if(V.y>=W.y-K&&V.y<=W.y+W.h+K){var P=X.x+K;var Q;if(V.y=W.y-K&&V.y<=W.y+W.h+K){var P=X.x-K;var Q;if(V.y=W.x&&E.x<=ad){var x=W.x+W.w/2;if(V.xU?ad+K:U+K}if(E.yX.x){var P=X.x+R/2;O.push({x:P,y:X.y});O.push({x:P,y:V.y})}else{var F=W.y+W.h;var N=E.y+E.h;var P=X.x+K;var Q;if(N>=W.y&&E.y<=F){var x=W.y+W.h/2;if(V.yN?F+K:N+K}if(E.x+E.w>X.x){P=E.x+E.w+K}}else{if(V.yX.x&&V.y>X.y){O.push({x:V.x,y:X.y})}else{if(V.x>X.x&&E.x>X.x){var P;if(E.x-X.xW.y+W.h){var F=W.y+W.h;var P=X.x+K;var Q;if(V.y-FX.x){P=U+K}else{P=X.x+K}var Q;if(V.yX.y){O.push({x:V.x,y:X.y})}else{if(V.x=X.x&&V.y>W.y+W.h){var F=W.y+W.h;var P=X.x-K;var Q;if(V.y-FX.x&&V.yX.x&&E.x>X.x){var P;if(E.x-X.xX.x){P=U+K}else{P=X.x+K}var Q;if(V.y>W.y+W.h){Q=V.y+K}else{Q=W.y+W.h+K}O.push({x:P,y:X.y});O.push({x:P,y:Q});O.push({x:V.x,y:Q})}}}}else{if((ab==3&&ac==4)||(ab==4&&ac==3)){if(ab==4){X=y;V=aa;S=false}else{X=aa;V=y;S=true}var W=Model.getShapeById(X.id).props;var E=Model.getShapeById(V.id).props;var U=E.x+E.w;if(V.x=X.x&&V.yW.y+W.h){Q=V.y+K}else{Q=W.y+W.h+K}O.push({x:P,y:X.y});O.push({x:P,y:Q});O.push({x:V.x,y:Q})}}}}}}}}}}}}}if(S){O.reverse()}}else{if(y.id!=null||aa.id!=null){var X,V,S,M;if(y.id!=null){X=y;V=aa;S=false;M=y.angle}else{X=aa;V=y;S=true;M=aa.angle}var Z=Model.getShapeById(X.id).props;if(M>=J/4&&M=I){O.push({x:X.x,y:V.y})}else{var x=I/2;O.push({x:X.x,y:X.y-x});O.push({x:V.x,y:X.y-x})}}else{O.push({x:X.x,y:X.y-K});if(R>=I){if(V.x>=Z.x-K&&V.x<=Z.x+Z.w+K){var L=Z.x+Z.w/2;if(V.x=Z.x-K&&V.x<=Z.x+Z.w+K){var L=Z.x+Z.w/2;if(V.x=J/4*3&&MX.x){if(R>=I){var x=R/2;O.push({x:X.x+x,y:X.y});O.push({x:X.x+x,y:V.y})}else{O.push({x:V.x,y:X.y})}}else{O.push({x:X.x+K,y:X.y});if(R>=I){if(V.y>=Z.y-K&&V.y<=Z.y+Z.h+K){var L=Z.y+Z.h/2;if(V.y=Z.y-K&&V.y<=Z.y+Z.h+K){var L=Z.y+Z.h/2;if(V.y=J/4*5&&MX.y){if(R>=I){O.push({x:X.x,y:V.y})}else{var x=I/2;O.push({x:X.x,y:X.y+x});O.push({x:V.x,y:X.y+x})}}else{O.push({x:X.x,y:X.y+K});if(R>=I){if(V.x>=Z.x-K&&V.x<=Z.x+Z.w+K){var L=Z.x+Z.w/2;if(V.x=Z.x-K&&V.x<=Z.x+Z.w+K){var L=Z.x+Z.w/2;if(V.x=I){var x=R/2;O.push({x:X.x-x,y:X.y});O.push({x:X.x-x,y:V.y})}else{O.push({x:V.x,y:X.y})}}else{O.push({x:X.x-K,y:X.y});if(R>=I){if(V.y>=Z.y-K&&V.y<=Z.y+Z.h+K){var L=Z.y+Z.h/2;if(V.y=Z.y-K&&V.y<=Z.y+Z.h+K){var L=Z.y+Z.h/2;if(V.y=I){var x=(aa.x-y.x)/2;O.push({x:y.x+x,y:y.y});O.push({x:y.x+x,y:aa.y})}else{var x=(aa.y-y.y)/2;O.push({x:y.x,y:y.y+x});O.push({x:aa.x,y:y.y+x})}}}}else{if(G.linkerType=="curve"){var y=G.from;var aa=G.to;var Y=this.measureDistance(y,aa);var T=Y*0.4;function H(e,d){if(e.id!=null){return{x:e.x-T*Math.cos(e.angle),y:e.y-T*Math.sin(e.angle)}}else{var c=Math.abs(e.y-d.y);var f=Math.abs(e.x-d.x);var b=Math.atan(c/f);var a={};if(e.x<=d.x){a.x=e.x+T*Math.cos(b)}else{a.x=e.x-T*Math.cos(b)}if(e.y<=d.y){a.y=e.y+T*Math.sin(b)}else{a.y=e.y-T*Math.sin(b)}return a}}O.push(H(y,aa));O.push(H(aa,y))}}return O},getLinkerLinePoints:function(i){var f=[];if(i.linkerType!="curve"){f.push(i.from);f=f.concat(i.points)}else{var j=0.05;var g=0;while(g<=1){var h={x:(1-g)*(1-g)*(1-g)*i.from.x+3*(1-g)*(1-g)*g*i.points[0].x+3*(1-g)*g*g*i.points[1].x+g*g*g*i.to.x,y:(1-g)*(1-g)*(1-g)*i.from.y+3*(1-g)*(1-g)*g*i.points[0].y+3*(1-g)*g*g*i.points[1].y+g*g*g*i.to.y};f.push(h);g+=j}}f.push(i.to);return f},getLinkerBox:function(l){var i=this.getLinkerLinePoints(l);var o=i[0].x;var p=i[0].y;var q=i[0].x;var r=i[0].y;for(var n=0;nq){q=k.x}}if(k.yr){r=k.y}}}var m={x:o,y:p,w:q-o,h:r-p};return m},getShapeBox:function(e){var d=e.props;var f=e.props.angle;return this.getRotatedBox(d,f)},getRotatedBox:function(p,r,u){if(r==0){return p}else{if(!u){u={x:p.x+p.w/2,y:p.y+p.h/2}}var l=this.getRotated(u,{x:p.x,y:p.y},r);var m=this.getRotated(u,{x:p.x+p.w,y:p.y},r);var n=this.getRotated(u,{x:p.x+p.w,y:p.y+p.h},r);var o=this.getRotated(u,{x:p.x,y:p.y+p.h},r);var q=Math.min(l.x,m.x,n.x,o.x);var t=Math.max(l.x,m.x,n.x,o.x);var s=Math.min(l.y,m.y,n.y,o.y);var v=Math.max(l.y,m.y,n.y,o.y);return{x:q,y:s,w:t-q,h:v-s}}},getRotated:function(n,h,j){var k=this.measureDistance(n,h);if(k==0||j==0){return h}var m=Math.atan(Math.abs(h.x-n.x)/Math.abs(n.y-h.y));if(h.x>=n.x&&h.y>=n.y){m=Math.PI-m}else{if(h.x<=n.x&&h.y>=n.y){m=Math.PI+m}else{if(h.x<=n.x&&h.y<=n.y){m=Math.PI*2-m}}}m=m%(Math.PI*2);var l=(m+j)%(Math.PI*2);var i={x:n.x+Math.sin(l)*k,y:n.y-Math.cos(l)*k};return i},getShapeAnchorInLinker:function(H){var A=H.getAnchors();var G=[];var t={x:H.props.x+H.props.w/2,y:H.props.y+H.props.h/2};for(var v=0;v=0;w--){var z=Model.orderList[w].id;var i=Model.getShapeById(z);if(i.name!="linker"){continue}var B=i;var u=null;F=3;for(var v=0;v-1){if(u==null){u={linker:B,anchors:[],type:"line"}}u.anchors.push(J)}}}if(u!=null){C.push(u)}}return C},getEndpointAngle:function(m,k){var i;if(k=="from"){i=m.from}else{i=m.to}var n;if(m.linkerType=="normal"){if(k=="from"){n=m.to}else{n=m.from}}else{if(m.linkerType=="broken"){if(k=="from"){n=m.points[0]}else{n=m.points[m.points.length-1]}}else{var l=12;var h;var j=Utils.measureDistance(m.from,m.to);if(k=="from"){h=l/j}else{h=1-l/j}n={x:(1-h)*(1-h)*(1-h)*m.from.x+3*(1-h)*(1-h)*h*m.points[0].x+3*(1-h)*h*h*m.points[1].x+h*h*h*m.to.x,y:(1-h)*(1-h)*(1-h)*m.from.y+3*(1-h)*(1-h)*h*m.points[0].y+3*(1-h)*h*h*m.points[1].y+h*h*h*m.to.y}}}return this.getAngle(n,i)},getAngle:function(f,e){var d=Math.atan(Math.abs(f.y-e.y)/Math.abs(f.x-e.x));if(e.x<=f.x&&e.y>f.y){d=Math.PI-d}else{if(e.x=f.x&&e.y0){for(var o=0;o0){for(var e=0;e=0;c--){var f=Model.orderList[c].id;if(e.id!=f&&!Utils.isSelected(f)&&l.indexOf(f)<0){var d=Model.getShapeById(f);if(!d.attribute||typeof d.attribute.container=="undefined"||d.attribute.container==false){if(!Utils.isFamilyShape(d,e)){var a=Utils.getShapeBox(d);if(Utils.rectInRect(a,e.props)){b.push(d);l.push(f)}}}}}return b}return h},getAttachedShapes:function(p){var r=[];for(var m=0;m=0;o--){var i=Model.orderList[o].id;var n=Model.getShapeById(i);if(n.attachTo==j.id&&!Utils.isSelected(i)&&r.indexOf(i)<0){q.push(n)}}l=l.concat(q)}}return l},copy:function(b){return $.extend(true,{},b)},rangeChildren:function(s){var v=[];if(s.children&&s.children.length>0){if(s.name=="verticalPool"){var h=[];var y=[];for(var u=0;u-1){continue}v.push(m[i])}}x.props.x=q;Designer.painter.renderShape(x);v.push(x);q+=x.props.w}y.sort(function(a,b){return a.props.y-b.props.y});var r=s.props.y+40;for(var u=0;u-1){continue}v.push(m[i])}}x.props.y=r;Designer.painter.renderShape(x);v.push(x);r+=x.props.h}y.sort(function(a,b){return a.props.x-b.props.x});var q=s.props.x+40;for(var u=0;u=0;c--){var g=Model.orderList[c].id;var d=Model.getShapeById(g);if(d.attribute&&d.attribute.collapseBy==f.id&&a.indexOf(g)<0){h.push(d)}}k=k.concat(h)}}return k},getCollapsedShapesById:function(e){var a=[];for(var c=Model.orderList.length-1;c>=0;c--){var d=Model.orderList[c].id;var b=Model.getShapeById(d);if(b.attribute&&b.attribute.collapseBy==e){a.push(b)}}return a},getShapeLineStyle:function(a,b){if(b==false||!Model.define.theme||!Model.define.theme.shape){return $.extend({},Schema.shapeDefaults.lineStyle,a)}else{return $.extend({},Schema.shapeDefaults.lineStyle,Model.define.theme.shape.lineStyle,a)}},getLinkerLineStyle:function(a,b){if(b==false||!Model.define.theme||!Model.define.theme.linker){return $.extend({},Schema.linkerDefaults.lineStyle,a)}else{return $.extend({},Schema.linkerDefaults.lineStyle,Model.define.theme.linker.lineStyle,a)}},getShapeFontStyle:function(b,a){if(a==false||!Model.define.theme||!Model.define.theme.shape){return $.extend({},Schema.shapeDefaults.fontStyle,b)}else{return $.extend({},Schema.shapeDefaults.fontStyle,Model.define.theme.shape.fontStyle,b)}},getLinkerFontStyle:function(b,a){if(a==false||!Model.define.theme||!Model.define.theme.linker){return $.extend({},Schema.linkerDefaults.fontStyle,b)}else{return $.extend({},Schema.linkerDefaults.fontStyle,Model.define.theme.linker.fontStyle,b)}},getShapeFillStyle:function(a,b){if(b==false||!Model.define.theme||!Model.define.theme.shape){return $.extend({},Schema.shapeDefaults.fillStyle,a)}else{return $.extend({},Schema.shapeDefaults.fillStyle,Model.define.theme.shape.fillStyle,a)}},containsChinese:function(a){if(escape(a).indexOf("%u")>=0){return true}else{return false}},filterXss:function(a){a=a.toString();a=a.replace(//g,">");a=a.replace(/%3E/g,">");a=a.replace(/'/g,"'");a=a.replace(/"/g,""");return a}};var GradientHelper={createLinearGradient:function(m,j,k){var q=m.props;var p;var n;var o;if(q.w>q.h){p={x:0,y:q.h/2};n={x:q.w,y:q.h/2};o=(k.angle+Math.PI/2)%(Math.PI*2)}else{p={x:q.w/2,y:0};n={x:q.w/2,y:q.h};o=k.angle}if(o!=0){var r={x:q.w/2,y:q.h/2};p=Utils.getRotated(r,p,o);n=Utils.getRotated(r,n,o);if(p.x<0){p.x=0}if(p.x>m.props.w){p.x=m.props.w}if(p.y<0){p.y=0}if(p.y>m.props.h){p.y=m.props.h}if(n.x<0){n.x=0}if(n.x>m.props.w){n.x=m.props.w}if(n.y<0){n.y=0}if(n.y>m.props.h){n.y=m.props.h}}var l=j.createLinearGradient(p.x,p.y,n.x,n.y);l.addColorStop(0,"rgb("+k.beginColor+")");l.addColorStop(1,"rgb("+k.endColor+")");return l},createRadialGradient:function(l,h,g){var i=l.props;var k=i.h;if(i.w255){p=255}var g=Math.round(o+(255-o)/255*m);if(g>255){g=255}var b=Math.round(l+(255-l)/255*m);if(b>255){b=255}return p+","+g+","+b},getDarkerColor:function(q){var m=60;var n=q.split(",");var r=parseInt(n[0]);var o=parseInt(n[1]);var l=parseInt(n[2]);var p=Math.round(r-r/255*m);if(p<0){p=0}var g=Math.round(o-o/255*m);if(g<0){g=0}var b=Math.round(l-l/255*m);if(b<0){b=0}return p+","+g+","+b}};var MessageSource={batchSize:0,messages:[],withUndo:true,withMessage:true,withDock:true,undoStack:{stack:[],push:function(c,d){this.stack.push(c);if(typeof d=="undefined"){d=true}if(d){MessageSource.redoStack.stack=[]}Designer.events.push("undoStackChanged",this.stack.length)},pop:function(){var c=this.stack.length;if(c==0){return null}var d=this.stack[c-1];this.stack.splice(c-1,1);MessageSource.redoStack.push(d);Designer.events.push("undoStackChanged",this.stack.length);return d}},redoStack:{stack:[],push:function(b){this.stack.push(b);Designer.events.push("redoStackChanged",this.stack.length)},pop:function(){var c=this.stack.length;if(c==0){return null}var d=this.stack[c-1];this.stack.splice(c-1,1);MessageSource.undoStack.push(d,false);Designer.events.push("redoStackChanged",this.stack.length);return d}},beginBatch:function(){this.batchSize++},commit:function(){this.batchSize--;this.submit()},submit:function(){if(this.batchSize==0&&this.messages.length!=0){if(this.withDock){Dock.update(true)}if(this.withMessage==false){this.messages=[];return}if(this.withUndo){this.undoStack.push(this.messages)}if(chartId!=""){var c=JSON.stringify(this.messages);if(role!="trial"){$("#saving_tip").text("<@i18n resource='diagraming.saving'/>")}var d={action:"command",messages:c,ignore:"messages",name:userName};CLB.send(d,function(){if(role!="trial"){$("#saving_tip").text("<@i18n resource='diagraming.saved'/>")}})}this.messages=[]}},send:function(c,d){this.messages.push({action:c,content:d});this.submit()},receive:function(b){this.doWithoutMessage(function(){MessageSource.executeMessages(b,true);Utils.showLinkerControls();Utils.showLinkerCursor()})},undo:function(){var b=this.undoStack.pop();if(b==null){return}this.doWithoutUndo(function(){MessageSource.beginBatch();for(var k=0;k"); - $("#title_container").children("input").val(title.replace(/(^\s+)|(\s+$)/g, "")).select(); - $("#title_container").children("input").bind("blur", - function() { - changeTitle(); - }).bind("keydown", function(e) { - if (e.keyCode == 13) { - changeTitle(); - } - }); - }); - function changeTitle() { - var newTitle = $.trim($("#title_container").children("input").val()); - newTitle = newTitle.replace(/(^\s+)|(\s+$)/g, ""); - var oldTitle = $(".diagram_title").text(); - oldTitle = oldTitle.replace(/(^\s+)|(\s+$)/g, ""); - if (newTitle != oldTitle && chartId != "") { - var msgObj = { - action : "changeTitle", - title : newTitle - }; - CLB.send(msgObj); - } - var title = newTitle != "" ? newTitle : oldTitle; - $("title").text(title); - $(".diagram_title").text(title).show(); - $("#title_container").children("input").remove(); - // 更新父级的相关数据 - awsui.ajax.request({ - url : './jd?cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_updatetitle&sid=' - + encodeURIComponent(sid) - + '&uuid=' - + ruuid - + '&title=' - + encodeURIComponent(title) - + '&processDefId=' - + process.processDefId - + '&appId=' - + appId, - async : false,// 同步,默认为异步 - ok : function(msg) { - //同步设置文件属性中的流程名称 - $("#file_attribute").contents().find("input[id='plName']").val(title); - try { - window.opener.parent.window.top.document.main_iframe.teamAppFrame.contentWindow._d157b007c785d2d988d3d81c8ddcb1b8.contentWindow.refresh(); - } catch(e) { - try { - window.opener.parent.window.top.document.main_iframe.teamAppFrame.contentWindow._d157b007c785d2d988d3d81c8ddcb1b8.contentWindow.refresh(); - - } catch(e) {} - } - if (parent.repositoryTree) { - parent.repositoryTree.refreshNodeById({ - id : ruuid, - name : title - }); - } - if (parent.awsTabs) { - parent.awsTabs.setTitle(ruuid, title); - } - if(Model.define.coeProperties ){ - Model.define.coeProperties.fileName = title; - } - } - }) - } - /** ############################Toolbar列表############################ */ - // 撤销 - $("#bar_undo").button({ - onClick : function() { - MessageSource.undo(); - } - }); - // 恢复 - $("#bar_redo").button({ - onClick : function() { - MessageSource.redo(); - } - }); - // 格式刷 - $("#bar_brush").button({ - onClick : function() { - if ($("#bar_brush").button("isSelected")) { - // 取消格式刷 - $("#bar_brush").button("unselect"); - $("#designer_op_help").hide(); - $(document).unbind("keydown.cancelbrush"); - Utils.selectCallback = null; - } else { - Designer.clipboard.brush(); - } - } - }); - // 字体 - $("#bar_font_family").button({ - onMousedown : function() { - $("#font_list").dropdown({ - target : $("#bar_font_family"), - onSelect : function(item) { - var font = item.text(); - Designer.setFontStyle({ - fontFamily : font - }); - $("#bar_font_family").button("setText", - font); - } - }); - // 选中 - var family = $("#bar_font_family").text().trim(); - $("#font_list").children().each(function() { - if ($(this).text() == family) { - $("#font_list").dropdown("select", - $(this)); - return false; - } - }); - } - }); - // 字号 - $("#bar_font_size").spinner({ - min : 12, - max : 100, - step : 1, - unit : "px", - onChange : function(val) { - Designer.setFontStyle({ - size : val - }); - } - }); - $("#bar_font_size").spinner("setValue", "13px"); - // 加粗 - $("#bar_font_bold").button({ - onClick : function() { - var bold = !$("#bar_font_bold").button("isSelected"); - Designer.setFontStyle({ - bold : bold - }); - $("#bar_font_bold").toggleClass("selected"); - } - }); - // 斜体 - $("#bar_font_italic").button({ - onClick : function() { - var italic = !$("#bar_font_italic") - .button("isSelected"); - Designer.setFontStyle({ - italic : italic - }); - $("#bar_font_italic").toggleClass("selected"); - } - }); - // 下划线 - $("#bar_font_underline").button({ - onClick : function() { - var underline = !$("#bar_font_underline") - .button("isSelected"); - Designer.setFontStyle({ - underline : underline - }); - $("#bar_font_underline").toggleClass("selected"); - } - }); - // 字体颜色 - $("#bar_font_color").button({ - onMousedown : function() { - var color = $("#bar_font_color").button("getColor"); - $.colorpicker({ - target : $("#bar_font_color"), - onSelect : function(color) { - Designer.setFontStyle({ - color : color - }); - $("#bar_font_color").button("setColor", - color) - }, - color : color - }); - } - }); - // 文本对齐 - $("#bar_font_align").button({ - onMousedown : function() { - $("#font_align_list").dropdown({ - target : $("#bar_font_align"), - onSelect : function(item) { - var align = {}; - align[item.attr("cate")] = item - .attr("al"); - Designer.setFontStyle(align); - } - }); - } - }); - // 填充 - $("#bar_fill").button({ - onMousedown : function() { - var color = $("#bar_fill").button("getColor"); - $.colorpicker({ - target : $("#bar_fill"), - onSelect : function(color) { - Designer.setFillStyle({ - type : "solid", - color : color - }); - $("#bar_fill").button("setColor", color) - }, - color : color, - extend : "
    " - }); - $("#bar_fill_gradient").unbind().bind("click", function() { - Designer.setFillStyle({ - type : "gradient" - }); - $("#color_picker").dropdown("close"); - }); - $("#bar_fill_img").unbind().bind("click", function() { - UI.showImageSelect(function(fileId, w, h) { - Designer.setFillStyle({ - type : "image", - fileId : fileId, - imageW : w, - imageH : h - }); - }); - $("#color_picker").dropdown("close"); - }); - $("#bar_fill_more").unbind().bind("click", function() { - Dock.showView("graphic"); - $("#color_picker").dropdown("close"); - }); - } - }); - // 线条颜色 - $("#bar_line_color").button({ - onMousedown : function() { - var color = $("#bar_line_color").button("getColor"); - $.colorpicker({ - target : $("#bar_line_color"), - onSelect : function(color) { - Designer.setLineStyle({ - lineColor : color - }); - $("#bar_line_color").button("setColor", - color) - }, - color : color - }); - } - }); - // 线条宽度 - $("#bar_line_width").button({ - onMousedown : function() { - $("#line_width_list").dropdown({ - target : $("#bar_line_width"), - onSelect : function(item) { - var width = parseInt(item.text()); - Designer.setLineStyle({ - lineWidth : width - }); - } - }); - // 选中 - var width = Utils.getSelected()[0].lineStyle.lineWidth; - $("#line_width_list").children().each(function() { - if (parseInt($(this).text()) == width) { - $("#line_width_list").dropdown("select", - $(this)); - } - }); - } - }); - // 线条样式 - $("#bar_line_style").button({ - onMousedown : function() { - $("#line_style_list").dropdown({ - target : $("#bar_line_style"), - onSelect : function(item) { - var lineStyle = item.attr("line"); - Designer.setLineStyle({ - lineStyle : lineStyle - }); - } - }); - // 选中 - var style = Utils.getSelected()[0].lineStyle.lineStyle; - var item = $("#line_style_list").children("li[line=" + style - + "]"); - $("#line_style_list").dropdown("select", item); - } - }); - // 连接线类型 - $("#bar_linkertype").button({ - onMousedown : function() { - $("#line_type_list").dropdown({ - target : $("#bar_linkertype"), - onSelect : function(item) { - var type = item.attr("tp"); - Designer.setLinkerType(type); - var cls = item.children("div").attr("class"); - $("#bar_linkertype").children("div:eq(0)").attr( - "class", cls); - } - }); - } - }); - // 开始箭头 - $("#bar_beginarrow").button({ - onMousedown : function() { - $("#beginarrow_list").dropdown({ - target : $("#bar_beginarrow"), - onSelect : function(item) { - var arrow = item.attr("arrow"); - Designer.setLineStyle({ - beginArrowStyle : arrow - }); - var cls = item.children("div").attr("class"); - $("#bar_beginarrow").children("div:eq(0)").attr( - "class", cls); - } - }); - // 选中 - var style = Utils.getSelectedLinkers()[0].lineStyle.beginArrowStyle; - var item = $("#beginarrow_list").children("li[arrow=" + style - + "]"); - $("#beginarrow_list").dropdown("select", item); - } - }); - // 结束箭头 - $("#bar_endarrow").button({ - onMousedown : function() { - $("#endarrow_list").dropdown({ - target : $("#bar_endarrow"), - onSelect : function(item) { - var arrow = item.attr("arrow"); - Designer.setLineStyle({ - endArrowStyle : arrow - }); - var cls = item.children("div").attr("class"); - $("#bar_endarrow").children("div:eq(0)").attr("class", - cls); - } - }); - // 选中 - var style = Utils.getSelectedLinkers()[0].lineStyle.endArrowStyle; - var item = $("#endarrow_list").children("li[arrow=" + style - + "]"); - $("#endarrow_list").dropdown("select", item); - } - }); - // 顶层底层 - $("#bar_front").button({ - onClick : function() { - Designer.layerShapes("front"); - } - }); - $("#bar_back").button({ - onClick : function() { - Designer.layerShapes("back"); - } - }); - // 加解锁 - $("#bar_lock").button({ - onClick : function() { - Designer.lockShapes(); - } - }); - $("#bar_unlock").button({ - onClick : function() { - Designer.unlockShapes(); - } - }); - $("#bar_link").button({ - onClick : function() { - UI.showInsertLink(); - } - }); - $("#bar_risk").button({ - onClick : function() { - UI.showRiskDlg(); - } - }); - $("#bar_importShape").button({ - onClick : function() { - UI.showImportShapeDlg(); - } - }); - $("#bar_import").button({ - onClick : function() { - UI.showImportDlg(); - } - }); - //by bzp 上传制度附件 - $("#bar_importPolicyFile").button({ - onClick : function() { - UI.showImportPolicyFileDlg(); - } - }); - //by bzp end - $("#bar_upfile").button({ - onClick: function() { - openUpFile() - } - }); - $("#bar_activityNo").button({//节点按照编号排序 - onClick: function() { - UI.activityNoDlg(); - } - }); - /** ##############AWS新增工具栏菜单开始############# */ - // 排列 - $("#bar_arrange").button({ - onMousedown : function() { - $("#bar_list_arrange").dropdown({ - target : $("#bar_arrange"), - onSelect : function(item) { - menuSelected(item); - } - }); - } - }); - // 视图 - $("#bar_view").button({ - onMousedown : function() { - $("#bar_list_view").dropdown({ - target : $("#bar_view"), - onSelect : function(item) { - menuSelected(item); - } - }); - } - }); - // 插入 - /* - * $("#bar_insert").button({ onMousedown : function() { - * $("#bar_list_insert").dropdown({ target : $("#bar_insert"), onSelect : - * function(item) { menuSelected(item); } }); } }); - */ - /** ##############AWS新增工具栏菜单结束############# */ - - /** ##############菜单列表############## */ - $("#menu_bar").children().bind("mousedown", function(e) { - var tar = $(this); - showMenuBarList(tar); - e.stopPropagation(); - }); - $("#menu_bar").children().bind("mouseenter", function() { - var tar = $(this); - if ($("#ui_container").find(".options_menu:visible").length > 0) { - showMenuBarList(tar); - } - }); - - function showMenuBarList(menuBar) { - var menuId = menuBar.attr("menu"); - // 只读 - if (menuBar.hasClass("readonly")) { - return; - } - $("#" + menuId).dropdown({ - target : menuBar, - onSelect : function(item) { - menuSelected(item); - } - }); - if (menuId == "bar_list_page") { - if (Model.define.page.showGrid) { - $("#bar_list_page").dropdown( - "select", - $("#bar_list_page") - .children("li[ac=set_page_showgrid]")); - } else { - $("#bar_list_page").dropdown( - "unselect", - $("#bar_list_page") - .children("li[ac=set_page_showgrid]")); - } - var item = $("#bar_list_pagesize li[w=" - + Model.define.page.width + "][h=" - + Model.define.page.height + "]"); - if (item.length > 0) { - $("#bar_list_pagesize").dropdown("select", item); - } else { - $("#bar_list_pagesize").dropdown("select", - $("#page_size_custom")); - } - $("#page_size_w").spinner("setValue", - Model.define.page.width + "px"); - $("#page_size_h").spinner("setValue", - Model.define.page.height + "px"); - item = $("#bar_list_padding").children("li[p=" - + Model.define.page.padding + "]"); - $("#bar_list_padding").dropdown("select", item); - item = $("#bar_list_gridsize").children("li[s=" - + Model.define.page.gridSize + "]"); - $("#bar_list_gridsize").dropdown("select", item); - } else if (menuId == "bar_list_view") { - var item = $("#bar_list_view").children(".static[zoom='" - + Designer.config.scale + "']"); - if (item.length) { - $("#bar_list_page").dropdown("select", item); - } - } - } - - function menuSelected(item) { - var action = item.attr("ac"); - // 编辑菜单 - if (action == "rename") { - $(".diagram_title").trigger("click"); - } else if (action == "close") { - if (parent.closeTabById) { - parent.closeTabById(chartId); - } else { - window.close(); - } - - } else if (action == "saveAs") { - UI.showSaveAs(); - } else if (action == "preview") {//在线预览流程图片 - UI.doPreview(); - } else if (action == "saveImage") {//生成图片和缩略图 - UI.saveImage(); - } else if (action == "versionCompare") { - UI.showVersionCompare(); - } else if (action == "output") {// 导出流程手册并预览 - UI.doOutputProcess(); - } else if (action == "export") { - $("#export_dialog").dlg(); - } else if (action == "processExport") { - UI.processExport(); - } else if (action == "undo") { - MessageSource.undo(); - } else if (action == "redo") { - MessageSource.redo(); - } else if (action == "cut") { - Designer.clipboard.cut(); - } else if (action == "copy") { - Designer.clipboard.copy(); - } else if (action == "paste") { - Designer.clipboard.paste(); - } else if (action == "duplicate") { - Designer.clipboard.duplicate(); - } else if (action == "brush") { - Designer.clipboard.brush(); - } else if (action == "selectall") { - Designer.selectAll(); - } else if (action == "openNewPage") { - UI.openNewPage();//新页面打开 - } else if (action == "batchreplace") { - UI.batchReplace(); - } else if (action == "delete") { - Designer.op.removeShape(); - // 视图缩放 - } else if (action == "zoom") { - var zoom = item.attr("zoom"); - if (zoom == "in") { - Designer.zoomIn(); - } else if (zoom == "out") { - Designer.zoomOut(); - } else { - var zoomScale = parseFloat(zoom); - Designer.setZoomScale(zoomScale); - } - // 插入 - } else if (action == "insert") { - var insertType = item.attr("in"); - if (insertType == "text") { - Designer.op.changeState("creating_free_text"); - } else if (insertType == "image") { - UI.showImageSelect(function(fileId, w, h) { - UI.insertImage(fileId, w, h); - }); - } else if (insertType == "line") { - Designer.op.changeState("creating_free_linker"); - } - // 页面 - } else if (action == "set_page_size") { - var w = parseInt(item.attr("w")); - var h = parseInt(item.attr("h")); - Designer.setPageStyle({ - width: w, - height: h - }); - } else if (action == "set_page_padding") { - var p = parseInt(item.attr("p")); - Designer.setPageStyle({ - padding: p - }) - } else if (action == "set_page_showgrid") { - if (item.menuitem("isSelected")) { - item.menuitem("unselect"); - Designer.setPageStyle({ - showGrid: false - }); - } else { - item.menuitem("select"); - Designer.setPageStyle({ - showGrid: true - }); - } - } else if (action == "set_page_gridsize") { - var s = parseInt(item.attr("s")); - Designer.setPageStyle({ - gridSize: s - }) - } - // 排列 - else if (action == "front") { - Designer.layerShapes("front"); - } else if (action == "back") { - Designer.layerShapes("back"); - } else if (action == "forward") { - Designer.layerShapes("forward"); - } else if (action == "backward") { - Designer.layerShapes("backward"); - } else if (action == "align_shape") { - var align = item.attr("al"); - Designer.alignShapes(align); - } else if (action == "distribute_shape") { - var type = item.attr("dis"); - Designer.distributeShapes(type); - } else if (action == "match_size") { - if (item.attr("custom")) { - Dock.showView("metric"); - } else { - var type = {}; - var w = item.attr("w"); - var h = item.attr("h"); - if (w) { - type.w = w; - } - if (h) { - type.h = h; - } - Designer.matchSize(type); - } - } else if (action == "lock") { - Designer.lockShapes(); - } else if (action == "unlock") { - Designer.unlockShapes(); - } else if (action == "group") { - Designer.group(); - } else if (action == "ungroup") { - Designer.ungroup(); - } else if (action == "hotkey") { - UI.showHotKey(); - } else if (action == "feedback") { - UI.showFeedBack(); - } else if (action == "getting_started") { - UI.gettingStart(); - } - } - $("#page_size_w").spinner({ - min : 200, - unit : "px", - step : 100, - onChange : function(val) { - Designer.setPageStyle({ - width : val - }); - } - }); - $("#page_size_h").spinner({ - min : 200, - unit : "px", - step : 100, - onChange : function(val) { - Designer.setPageStyle({ - height : val - }); - } - }); - // 给设置页面背景色,放一个colorpicker - var pickerHtml = $("#color_picker").html(); - var newPicker = $("").appendTo($("#bar_page_color")); - newPicker.css("right", "-179px"); - newPicker.children(".color_items").children("div").unbind().bind( - "click", function() { - var color = $(this).css("background-color"); - color = color.replace(/\s/g, ""); - color = color.substring(4, color.length - 1); - Designer.setPageStyle({ - backgroundColor : color - }); - $("#bar_list_page").dropdown("close"); - }); - // 抛出事件,控制状态 - Designer.events.push("selectChanged", 0); - Designer.events.push("clipboardChanged", 0); - Designer.events.push("undoStackChanged", 0); - Designer.events.push("redoStackChanged", 0); - }, - /** - * 更新UI - */ - update : function() { - var selectedIds = Utils.getSelectedIds(); - var count = selectedIds.length; - var linkerIds = Utils.getSelectedLinkerIds(); - var linkerCount = linkerIds.length; - var shapeIds = Utils.getSelectedShapeIds(); - var shapeCount = shapeIds.length; - var lockedCount = Utils.getSelectedLockedIds().length; - var groupCount = Utils.getSelectedGroups().length; - // 排列菜单 - var arrangeMenu = $("#bar_list_arrange"); - if (count == 0) { - $(".toolbar").find(".selected").removeClass("selected"); - // 没有选中,让某些按钮失效 - if ($("#designer_op_help").is(":visible")) { - $("#bar_brush").button("enable"); - $("#bar_brush").button("select"); - } else { - $("#bar_brush").button("disable"); - } - // 字体 - $("#bar_font_family").button("disable"); - $("#bar_font_size").button("disable"); - $("#bar_font_bold").button("disable"); - $("#bar_font_italic").button("disable"); - $("#bar_font_underline").button("disable"); - $("#bar_font_color").button("disable"); - $("#bar_font_align").button("disable"); - // 线条 - $("#bar_line_color").button("disable"); - $("#bar_line_width").button("disable"); - $("#bar_line_style").button("disable"); - // 顶层底层 - $("#bar_front").button("disable"); - $("#bar_back").button("disable"); - // 锁定 - $("#bar_lock").button("disable"); - // 编辑菜单 - var editMenu = $("#bar_list_edit"); - editMenu.children("li[ac=cut]").menuitem("disable"); - editMenu.children("li[ac=copy]").menuitem("disable"); - editMenu.children("li[ac=duplicate]").menuitem("disable"); - editMenu.children("li[ac=brush]").menuitem("disable"); - editMenu.children("li[ac=delete]").menuitem("disable"); - // 排列菜单 - arrangeMenu.children("li[ac=front]").menuitem("disable"); - arrangeMenu.children("li[ac=back]").menuitem("disable"); - arrangeMenu.children("li[ac=forward]").menuitem("disable"); - arrangeMenu.children("li[ac=backward]").menuitem("disable"); - arrangeMenu.children("li[ac=lock]").menuitem("disable"); - // 节点编号排序 - $("#bar_activityNo").button("enable"); - $("#bar_activityNo div").removeClass('extend_activityNoDisable'); - $("#bar_activityNo div").addClass('extend_activityNo'); - } else { - if (editable) { - // 选中,让某些按钮激活 - $("#bar_brush").button("enable"); - if ($("#designer_op_help").is(":visible")) { - $("#bar_brush").button("select"); - } - $("#bar_font_family").button("enable"); - $("#bar_font_size").button("enable"); - $("#bar_font_bold").button("enable"); - $("#bar_font_italic").button("enable"); - $("#bar_font_underline").button("enable"); - $("#bar_font_color").button("enable"); - $("#bar_font_align").button("enable"); - // 线条 - $("#bar_line_color").button("enable"); - $("#bar_line_width").button("enable"); - $("#bar_line_style").button("enable"); - // 顶层底层 - $("#bar_front").button("enable"); - $("#bar_back").button("enable"); - // 锁定 - $("#bar_lock").button("enable"); - // 编辑菜单 - var editMenu = $("#bar_list_edit"); - editMenu.children("li[ac=cut]").menuitem("enable"); - editMenu.children("li[ac=copy]").menuitem("enable"); - editMenu.children("li[ac=duplicate]").menuitem("enable"); - editMenu.children("li[ac=brush]").menuitem("enable"); - editMenu.children("li[ac=delete]").menuitem("enable"); - // 排列菜单 - arrangeMenu.children("li[ac=front]").menuitem("enable"); - arrangeMenu.children("li[ac=back]").menuitem("enable"); - arrangeMenu.children("li[ac=forward]").menuitem("enable"); - arrangeMenu.children("li[ac=backward]").menuitem("enable"); - arrangeMenu.children("li[ac=lock]").menuitem("enable"); - // 设置Toolbar样式 - var shape = Model.getShapeById(selectedIds[0]); - $("#bar_font_family").button("setText", shape.fontStyle.fontFamily); - $("#bar_font_size") - .spinner("setValue", shape.fontStyle.size + "px"); - if (shape.fontStyle.bold) { - $("#bar_font_bold").button("select"); - } else { - $("#bar_font_bold").button("unselect"); - } - if (shape.fontStyle.italic) { - $("#bar_font_italic").button("select"); - } else { - $("#bar_font_italic").button("unselect"); - } - if (shape.fontStyle.underline) { - $("#bar_font_underline").button("select"); - } else { - $("#bar_font_underline").button("unselect"); - } - $("#bar_font_color").button("setColor", shape.fontStyle.color); - $("#bar_line_color").button("setColor", shape.lineStyle.lineColor); - - // 节点编号排序 - $("#bar_activityNo").button("disable"); - $("#bar_activityNo div").removeClass('extend_activityNo'); - $("#bar_activityNo div").addClass('extend_activityNoDisable'); - } - } - - // AWS增加的按钮需要被控制开始 - if (count == 0) { - $("#toolbar-data-attr").button("disable"); - // 节点属性 - $("#toolbar-data-attr").unbind("click"); - $("#bar_arrange").button("disable"); - } else { - $("#toolbar-data-attr").button("enable"); - // 节点属性 - $("#toolbar-data-attr").bind("click", function() { - showPropertiesDialog(); - }); - $("#bar_arrange").button("enable"); - } - // AWS增加的按钮需要被控制完毕 - - // 通过图形的数量,判读是否可以填充 - if (shapeCount == 0) { - $("#bar_fill").button("disable"); - $("#toolbar-shape-attr").button("disable"); //形状属性 - } else { - if (editable) { - $("#bar_fill").button("enable"); - } - var shape = Model.getShapeById(shapeIds[0]); - // 图形填充 - if (shape.fillStyle.type == "solid") { - $("#bar_fill").button("setColor", shape.fillStyle.color); - } else if (shape.fillStyle.type == "gradient") { - $("#bar_fill").button("setColor", shape.fillStyle.endColor); - } - if(shapeCount == 1 && shape.name == BPMN_TYPE_USER_TASK) { //控制值选择一个人工任务时形状属性可用 - $("#toolbar-shape-attr").button("enable"); //形状属性 - } else { - $("#toolbar-shape-attr").button("disable"); //形状属性 - } - } - if (shapeCount != 1) { - $("#bar_link, #bar_risk").button("disable"); - $("#dock_btn_shapeConfig").button("disable"); - $("#dock_btn_shapeConfig").bind('click', function() { - $.simpleAlert("请选择形状"); - }); - } else { - $("#dock_btn_shapeConfig").unbind('click'); - $("#dock_btn_shapeConfig").button("enable"); - if (editable) { - $("#bar_link").button("enable"); - } - // 关联/推送文件不显示 - if ($('#bar_rmark').length == 0 && $('#bar_cancel_aws_correlate').length == 0) { - $("#bar_risk").button("enable"); - } else { - $("#bar_risk").button("disable"); - } - } - // 通过连接线的数量,判断是否可以修改箭头等 - if (linkerCount == 0) { - $("#bar_linkertype").button("disable"); - $("#bar_beginarrow").button("disable"); - $("#bar_endarrow").button("disable"); - } else { - $("#bar_linkertype").button("enable"); - $("#bar_beginarrow").button("enable"); - $("#bar_endarrow").button("enable"); - var shape = Model.getShapeById(linkerIds[0]); - // 设置Toolbar的线条样式 - $("#bar_linkertype").children("div:eq(0)").attr("class", - "ico linkertype_" + shape.linkerType.toLowerCase()); - if ( typeof shape.lineStyle.beginArrowStyle != "undefined") { - $("#bar_beginarrow").children("div:eq(0)").attr( - "class", - "ico ico_arrow larrow_" - + shape.lineStyle.beginArrowStyle.toLowerCase()); - } - if ( typeof shape.lineStyle.endArrowStyle != "undefined") { - $("#bar_endarrow").children("div:eq(0)").attr( - "class", - "ico ico_arrow rarrow_" - + shape.lineStyle.endArrowStyle.toLowerCase()); - } - - - } - // 通过锁定的数量,判断是否可以解除锁定 - if (lockedCount == 0) { - $("#bar_unlock").button("disable"); - arrangeMenu.children("li[ac=unlock]").menuitem("disable"); - } else { - $("#bar_unlock").button("enable"); - arrangeMenu.children("li[ac=unlock]").menuitem("enable"); - } - // 是否激活组合、对齐,条件是选中图形要不少于2个 - if (count < 2) { - arrangeMenu.children("li[ac=group]").menuitem("disable"); - $("#bar_arrange_align").menuitem("disable"); - } else { - arrangeMenu.children("li[ac=group]").menuitem("enable"); - $("#bar_arrange_align").menuitem("enable"); - } - // 是否激活匹配大小,条件是选中形状要不少于2个 - if (shapeCount < 2) { - $("#bar_arrange_match").menuitem("disable"); - } else { - $("#bar_arrange_match").menuitem("enable"); - } - // 是否激活排列图形菜单,条件是选中图形要不少于3个 - if (count < 3) { - $("#bar_arrange_dist").menuitem("disable"); - } else { - $("#bar_arrange_dist").menuitem("enable"); - } - // 通过组合的数量,判断是否可以取消组合 - if (groupCount == 0) { - arrangeMenu.children("li[ac=ungroup]").menuitem("disable"); - } else { - arrangeMenu.children("li[ac=ungroup]").menuitem("enable"); - } - //文件串联分析工具在未选择图形的时候有效 - if($("#dock_btn_eteanalysis").length != 0) { - if (count == 0) { - $("#dock_btn_eteanalysis").find(".awsui-iconfont").css("color","black"); - $("#dock_btn_eteanalysis").button("enable"); - $("#dock_btn_eteanalysis").removeAttr("onclick"); - $("#dock_btn_eteanalysis").off("click").on("click", function(){ - var f = $('#eteCascadeAnalysisForm'); - f.find(':input[name=uuid]').val(ruuid); - f.submit(); - }); - } else { - $("#dock_btn_eteanalysis").find(".awsui-iconfont").css("color","gray"); - $("#dock_btn_eteanalysis").button("disable"); - $("#dock_btn_eteanalysis").removeAttr("onclick"); - $("#dock_btn_eteanalysis").off("click"); - } - } - }, - /** - * 打开插入链接 - */ - showInsertLink : function() { - $("#link_dialog").dlg(); - var addr = Utils.getSelected()[0].link; - if (!addr) { - addr = ""; - } - $("#linkto_addr").val(addr).select(); - $("#linkto_addr").unbind().bind("keydown", function(e) { - if (e.keyCode == 13) { - UI.setLink(); - } - }); - }, - /** - * 设置连接 - */ - setLink : function() { - var newLink = $("#linkto_addr").val(); - var shape = Utils.getSelected()[0]; - shape.link = newLink; - Model.update(shape); - $('#link_dialog').dlg('close'); - }, - /** - * 选中图片后的回调 - * - * @type {} - */ - imageSelectedCallback : null, - /** - * 打开图片选择 - */ - showImageSelect : function(callback) { - if (callback) { - this.imageSelectedCallback = callback; - } else { - this.imageSelectedCallback = null; - } - this.fetchingRequest = null; - var height = $(window).height() - 200; - if (height > 550) { - height = 550; - } else if (height < 200) { - height = 200; - } - $(".image_list").height(height); - // this.showImageSelectContent("upload"); - $("#image_dialog").dlg({ - onClose : function() { - if (UI.fetchingRequest) { - UI.fetchingRequest.abort(); - } - } - }); - // 加载用户图片 - if ($("#image_select_upload").is(":visible")) { - UI.loadUserImages(); - }; - // 左侧分类绑定事件 - $(".image_sources").children().unbind().bind("click", function() { - UI.showImageSelectContent($(this).attr("ty")); - }); - // 上传 - $("#upload_img_res").empty(); - $("#input_upload_image").unbind().bind("change", function() { - $("#upload_img_res") - .html("上传中..."); - $("#frm_upload_image").submitForm({ - success : function(result) { - if (result.result == "type_wrong") { - $("#upload_img_res").html("此文件不是图片,请重新选择"); - } else if (result.result == "size_wrong") { - $("#upload_img_res").html("文件大小超出要求,最大2M"); - } else if (result.result == "exception") { - $("#upload_img_res").html("无法使用此图片,请选择其他图片"); - } else { - var img = result.image; - UI.setShapeImage(img.fileId, img.imageW, - img.imageH); - } - } - }); - }); - // 输入URL - $("#input_img_url").val(""); - $("#img_url_area").empty(); - var oldUrl = ""; - function urlChanged() { - var url = $("#input_img_url").val().trim(); - if (url != oldUrl) { - oldUrl = url - if (url != "") { - if (url.indexOf("http") < 0) { - url = "http://" + url; - } - $("#img_url_area") - .html("正在加载预览..."); - var newImage = $("").appendTo("#img_url_area"); - newImage.unbind().bind("load", function() { - newImage.show().addClass("img_url_loaded"); - $(".img_url_loading_tip").remove(); - }).bind("error", function() { - $("#img_url_area") - .html("
    无法在此地址下加载图片。
    • 请检查图片地址是否输入正确。
    • 确保图片地址是公开的。
      "); - }); - } - } - } - $("#input_img_url").unbind().bind("paste", function() { - urlChanged(); - }).bind("keyup", function() { - urlChanged(); - }); - // 搜索 - $("#input_img_search").unbind().bind("keydown", function(e) { - if (e.keyCode == 13) { - UI.searchImgByGoogle(); - } - }); - $("#btn_img_search").unbind().bind("click", function() { - UI.searchImgByGoogle(); - }); - // 完成按钮 - $("#set_image_submit").button("enable"); - $("#set_image_submit").button({ - onClick : function() { - var currentTab = $(".image_sources").children(".active") - .attr("ty"); - if (currentTab == "upload") { - var selectedImg = $("#user_image_items") - .children(".image_item_selected"); - if (selectedImg.length > 0) { - var fileId = selectedImg.attr("fileId"); - var imageW = selectedImg.attr("w"); - var imageH = selectedImg.attr("h"); - UI.setShapeImage(fileId, imageW, imageH); - } else { - $("#image_dialog").dlg("close"); - } - } else if (currentTab == "url") { - if ($(".img_url_loaded").length > 0) { - var url = $(".img_url_loaded").attr("src"); - UI.setShapeImageByURL(url); - } else { - $("#image_dialog").dlg("close"); - } - } else { - // 搜索 - var selectedImg = $("#google_image_items") - .children(".image_item_selected"); - if (selectedImg.length > 0) { - var url = selectedImg.attr("u"); - UI.setShapeImageByURL(url); - } else { - $("#image_dialog").dlg("close"); - } - } - } - }); - // 取消按钮 - $("#set_image_cancel").button({ - onClick : function() { - $("#image_dialog").dlg("close"); - } - }); - $("#set_image_text").empty(); - }, - /** - * 显示图片设置类型 - */ - showImageSelectContent : function(type) { - $(".image_list").hide(); - $("#image_select_" + type).show().find("input[type=text]").select(); - $(".image_sources").children().removeClass("active"); - $(".image_sources").children("li[ty=" + type + "]").addClass("active"); - }, - /** - * 加载用户图片 - */ - loadUserImages : function(refresh) { - $("#user_image_items").empty(); - $.ajax({ - url : "/user_image/list", - success : function(data) { - if (data.images) { - for (var i = 0; i < data.images.length; i++) { - var img = data.images[i]; - UI.appendUserImage(img); - } - $("#user_image_items") - .append("
      "); - } - } - }); - $("#user_image_items").attr("loaded", "true"); - }, - searchIndex : 0, - searchKeywords : "", - /** - * 通过Google搜索图片 - */ - searchImgByGoogle : function() { - var keywords = $("#input_img_search").val(); - if (keywords.trim() != "") { - $("#google_image_items").empty(); - this.searchKeywords = encodeURI(keywords); - this.searchIndex = 0; - this.loadGoogleImg(); - } else { - $("#input_img_search").focus(); - } - }, - /** - * 加载Google图片 - */ - loadGoogleImg : function() { - $ - .getScript("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=" - + this.searchKeywords - + "&rsz=8&start=" - + (this.searchIndex * 16) - + "&callback=UI.googleImgCallback"); - $ - .getScript("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=" - + this.searchKeywords - + "&rsz=8&start=" - + (this.searchIndex * 16 + 8) - + "&callback=UI.googleImgCallback"); - $(".gg_img_more").remove(); - $("#google_image_items") - .append("
      正在加载图片...
      "); - this.searchIndex++; - }, - /** - * Google搜索回调 - * - * @param {} - * data - */ - googleImgCallback : function(data) { - var responseData = data.responseData; - var results = responseData.results; - for (var i = 0; i < results.length; i++) { - var item = results[i]; - UI.appendGoogleImage(item); - } - $("#google_image_items").append("
      "); - $(".img_gg_loading_tip").remove(); - $(".gg_img_more").remove(); - if (this.searchIndex <= 3) { - $("#google_image_items") - .append("
      显示更多结果...
      "); - } - }, - /** - * 添加一个用户图片 - */ - appendUserImage : function(img) { - var box = $("
      ").appendTo($("#user_image_items")); - box.unbind().bind("click", function() { - $(".image_item_selected") - .removeClass('image_item_selected'); - $(this).addClass('image_item_selected'); - }).bind("mouseenter", function() { - var target = $(this); - var remove = $("
      ") - .appendTo(target); - var id = target.attr("id"); - remove.bind("click", function() { - target.fadeOut(); - $.ajax({ - url : "/user_image/remove", - data : { - imageId : id - } - }); - }); - }).bind("mouseleave", function() { - $(this).find(".ico_remove_red").remove(); - }); - var location = img.fileId; - var newImage = $("").appendTo(box); - newImage.bind("load", function() { - $(this).css("margin-top", (140 - $(this).height()) / 2); - }); - }, - /** - * 添加一个Google搜索的图片 - */ - appendGoogleImage : function(img) { - var title = img.title + " (" + img.width + " × " + img.height + ")"; - var box = $("
      ").appendTo($("#google_image_items")); - box.unbind().bind("click", function() { - $(".image_item_selected") - .removeClass('image_item_selected'); - $(this).addClass('image_item_selected'); - }); - var newImage = $("").appendTo(box); - newImage.bind("load", function() { - $(this).css("margin-top", (140 - $(this).height()) / 2); - }); - }, - /** - * 设置形状的背景图片 - * - * @param {} - * source - */ - setShapeImage : function(fileId, w, h) { - if (this.imageSelectedCallback) { - this.imageSelectedCallback(fileId, w, h); - } - $("#image_dialog").dlg("close"); - }, - /** - * 加载URL图片的ajax请求对象 - * - * @type {} - */ - fetchingRequest : null, - /** - * 通过URL设置图片 - * - * @param {} - * url - */ - setShapeImageByURL : function(url) { - $("#set_image_text").removeClass("errored").text("正在应用图片,请稍候..."); - $("#set_image_submit").button("disable"); - UI.fetchingRequest = $.ajax({ - url : "/user_image/reference", - data : { - url : url - }, - success : function(result) { - if (result.result == "exception") { - $("#set_image_text").addClass("errored") - .html("无法使用此图片,请选择其他图片"); - } else { - $("#set_image_text").empty(); - var img = result.image; - UI - .setShapeImage(img.fileId, img.imageW, - img.imageH); - } - } - }); - }, - /** - * 插入图片 - * - * @param {} - * source - * @param {} - * location - * @param {} - * w - * @param {} - * h - */ - insertImage : function(fileId, w, h) { - w = parseInt(w); - h = parseInt(h); - var layout = $("#designer_layout"); - var centerX = layout.width() / 2 + layout.offset().left; - var centerY = layout.height() / 2 + layout.offset().top; - var pos = Utils.getRelativePos(centerX, centerY, $("#designer_canvas")); - var shape = Model.create("standardImage", pos.x.restoreScale() - w / 2, - pos.y.restoreScale() - h / 2); - shape.props.w = w; - shape.props.h = h; - shape.fillStyle = { - type : "image", - fileId : fileId, - display : "fill", - imageW : w, - imageH : h - }; - Model.add(shape); - Designer.painter.renderShape(shape); - Utils.unselect(); - Utils.selectShape(shape.id); - }, - /** - * 导出流程手册 - */ - doOutputProcess: function () { - }, - /** - * 加载预览数据 - */ - doPreview: function () { - if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") { - if (editable) { - $.simpleAlert('页面中有未保存的内容,请先保存'); - return; - } - } - $.simpleAlert('请稍后', 'loading'); - $.post("./jd", { - cmd: "com.actionsoft.apps.coe.pal_pl_repository_df", - sid: sid, - "uuid": chartId - }, function t(msg) { - $("#previewContent .procImg").remove(); - if (typeof(msg) == "string") { - msg = eval('(' + msg + ')'); - } - msg = msg.data.url; - if (msg == "") { - alert("请您先保存一个版本!"); - } else { - var img = $(""); - var hh = img.width(); - $("#previewContent").append(img); - } - $("#previewDialog").dialog({ - title: "预览", - width: window.innerWidth * 0.9, - height: window.innerHeight * 0.92 - }); - $.simpleAlert("close"); - }, "text"); - }, - /** - * 生成图片和缩略图 - */ - saveImage : function() { - if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") { - if (editable) { - $.simpleAlert('页面中有未保存的内容,请先保存'); - return; - } - } - $.simpleAlert('请稍后', 'loading'); - $.ajax({ - type: "POST", - url: "./jd", - data: { - sid: sid, - cmd: "com.actionsoft.apps.coe.pal_pl_repository_image_save", - uuid: chartId - }, - success: function (r, textStatus, jqXHR) { - if(r.result == 'ok' ) { - $.simpleAlert("close"); - $.simpleAlert('图片创建完成', 'ok', 2000, {callback:function() { - var options = { - title : "提示", - content:"是否打开图片预览", - onConfirm: function(){ - $.simpleAlert("close"); - UI.doPreview();// 预览 - }, - onCancel : function(){ - } - }; - $.confirm(options); - }}); - } else { - console.log(r); - $.simpleAlert("close"); - $.simpleAlert(r.data.desc, 'error'); - } - }, - error: function (jqXHR, textStatus, errorThrown) { - $.simpleAlert(errorThrown, 'err'); - console.log(jqXHR) - console.log(textStatus) - console.log(errorThrown) - } - }); - }, - showVersionCompare : function() { - $("#dialog_version_compare").dialog({ - buttons:[ - {text:'确定',cls:"blue",handler:function(){ - var checkboxs = $("input[name='version']:checked"); - var numCheck = checkboxs.length; - if (numCheck != 2) { - $.simpleAlert("请选择两个需要对比的版本", "warning"); - return; - } - var firstId; - var secondId; - var values = []; - var names = []; - checkboxs.each(function (){ - values.push($(this).val()); - names.push($(this).data("name")); - }); - firstId = values[0]; - secondId = values[1]; - awsui.ajax.post("./jd?sid="+sid+"&cmd=com.actionsoft.apps.coe.pal_pl_version_compare", { firstId: firstId, secondId: secondId}, function(data) { - $("#dialog_version_compare").dialog("close"); - var fileAttrCompare = data.fileAttrCompare; - var shapeAttrCompare = data.shapeAttrCompare; - var fileHtml = ""; - var shapeHtml = ""; - if (fileAttrCompare.length > 0) { - for (var i = 0; i < fileAttrCompare.length; i++) { - fileHtml += fileAttrCompare[i] + "
      "; - } - $("#fileAttr").html(fileHtml); - } - if (shapeAttrCompare.length > 0) { - for (var i = 0; i < shapeAttrCompare.length; i++) { - shapeHtml += shapeAttrCompare[i] + "
      "; - } - $("#shapeAttr").html(shapeHtml); - } - $("#versionCompareResult").show(); - $("#dialog_version_compare_result").dialog({ - - }); - }, 'json'); - } - } - ] - }); - }, - /** - * 流程导出 - */ - processExport : function() { - //先处理准备好导出的流程数据 - if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") { - if (editable) { - $.simpleAlert('页面中有未保存的内容,请先保存'); - return; - } - } - var repositoryIds = []; - repositoryIds.push(ruuid); - var options = { - title : "提示", - content:"确定导出并下载文件吗?", - onConfirm: function(){ - $.simpleAlert('正在导出', 'loading'); - $.ajax({ - type: "POST", - url: "./jd", - data: { - sid: sid, - cmd: "com.actionsoft.apps.coe.pal_pl_export_handle", - repositoryIds: JSON.stringify(repositoryIds) - }, - success: function (r, textStatus, jqXHR) { - if(r.result == 'ok' ) { - $.simpleAlert("close"); - $.simpleAlert('导出完成', 'ok', 2000, {callback:function() { - $.simpleAlert("close"); - // 下载 - $.ajax({ - type: "POST", - url: "./jd", - data: { - sid: sid, - cmd: "com.actionsoft.apps.coe.pal_pl_export", - exportTitle: r.data.exportTitle, - exportCount: r.data.exportCount, - dcId: r.data.dcId, - }, - success: function (r, textStatus, jqXHR) { - if(r.result == 'ok' ) { - window.location.href = r.data.downLoadUrl; - } else { - console.log(r); - } - }, - error: function (jqXHR, textStatus, errorThrown) { - $.simpleAlert(errorThrown, 'err'); - console.log(jqXHR) - console.log(textStatus) - console.log(errorThrown) - } - }); - }}); - } else { - console.log(r); - $.simpleAlert("close"); - } - }, - error: function (jqXHR, textStatus, errorThrown) { - $.simpleAlert(errorThrown, 'err'); - console.log(jqXHR) - console.log(textStatus) - console.log(errorThrown) - } - }); - }, - onCancel : function(){ - } - }; - $.confirm(options); - }, - openNewPage : function() { - window.open(location.href); - }, - /** - * 执行导出 - */ - doExport : function() { - // var definition = JSON.stringify(Model.define); - // $("#export_definition").val(definition); - // $("#export_title").val($(".diagram_title").text()); - // $("#export_form").submit(); - if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") { - if (editable) { - $.simpleAlert('页面中有未保存的内容,请先保存'); - return; - } - } - $.simpleAlert('请稍后', 'loading'); - var type = $('input[name="type"]:checked').val(); - $.post("./jd", { - cmd : "com.actionsoft.apps.coe.pal_pl_repository_download_png", - sid : sid, - "uuid" : chartId, - type : type - }, function t(msg) { - if (typeof(msg) == "string") { - msg = eval('(' + msg + ')'); - } - msg = msg.data.url; - if (msg == "") { - alert("请您先保存一个版本!"); - } else { - //window.open(msg); - $("#export_iframe").attr("src", msg); - } - $.simpleAlert("close"); - }, "text"); - $('#export_dialog').dlg('close'); - }, - /** - * 展示hotkey列表 - */ - showHotKey : function() { - var height = $(window).height() - 175; - if (height > 500) { - height = 500 + "px"; - } - $("#hotkey_list").dlg(); - $("#hotkey_list").css({ - "top" : "28px" - }); - $("#hotkey_list .dialog_content").css({ - "height" : height - }); - }, - /** - * 显示反馈dialog - */ - showFeedBack : function() { - $("#send_feedback").css({ - width : "auto", - height : "auto" - }); - var sendFeedBack = $("#send_feedback"); - sendFeedBack.dlg(); - $("#feedback_email").focus(); - $("#feedback_message").val(""); - $(".feedback_error_email_format").hide(); - $(".feedback_error_msg").hide(); - }, - /** - * 发送反馈 - */ - sendFeedBack : function(dom) { - $(".feedback_error_email_format").hide(); - $(".feedback_error_msg").hide(); - var email = $.trim($("#feedback_email").val()); - var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/; - if (!reg.test(email)) { - $("#feedback_email").focus(); - $(".feedback_error_email_format").show(); - return; - } - var feedbackMessage = $.trim($("#feedback_message").val()); - if (feedbackMessage == "") { - $("#feedback_message").val("").focus(); - $(".feedback_error_msg").show(); - return; - } - Util.ajax({ - url : "/support/save_ask", - data : { - content : feedbackMessage, - username : $("#feedback_name").val(), - email : email, - url : location.href - }, - success : function(data) { - $(".dlg_mask").remove(); - $("#send_feedback").animate({ - left : $(window).width(), - top : $(window).height(), - width : 0, - height : 0, - opacty : 0.2 - }); - } - }); - }, - /** - * 打开开始向导 - */ - gettingStart : function(delay) { - this.showStartStep(1); - }, - showStartStep : function(step, dom) { - $(".mark_content").hide(); - var content = $(".mark" + step + "_content"); - content.show(); - var top; - var left; - if (step == 1) { - top = $("#shape_panel").offset().top + 70; - left = $("#shape_panel").offset().left + $("#shape_panel").width() - + 10; - } else if (step == 2) { - top = $(".row2").offset().top + 30; - left = $("#menu_bar_insert").offset().left - + $("#menu_bar_insert").width() - content.outerWidth() / 2; - } else if (step == 3) { - top = $(".toolbar").offset().top + 40; - left = 270; - } else if (step == 4) { - top = $("#dock").offset().top + 10; - left = $("#dock").offset().left - content.outerWidth() - 10 - } else if (step == "created") { - top = dom.offset().top + dom.height() / 2 - content.outerHeight() - / 2; - if (top <= 0) { - top = 0; - } - if (top + content.outerHeight() > $(window).height()) { - top = $(window).height() - content.outerHeight(); - } - left = dom.offset().left + dom.width() + 10; - } - content.css({ - top : top, - left : left - }); - }, - /** - * 关闭开始向导 - * - * @param {} - * dom - */ - closeGettingStart : function(dom) { - $(".mark_content").hide(); - }, - /** - * Getting Start END-- - */ - - showAddColla : function() { - Util.ajax({ - url : "/collaboration/get_colla_role_list", - data : { - chartId : chartId - }, - success : function(data) { - $("#colla_dialog").find(".role_list").html(data).scrollTop(999); - $("#colla_dialog").removeClass("_update"); - $("#colla_dialog").css({ - "top" : ($(window).height() - $("#colla_dialog") - .outerHeight()) - * 0.5 + "px" - }); - $("#colla_dialog").dlg(); - $("#colla_suggest_box").empty(); - $("#add_prompt4").hide(); - $("#add_prompt3").hide(); - $("#add_prompt2").hide(); - $("#add_prompt1").show(); - } - }); - - var lastVal = ""; - $("#input_add_colla").val("").unbind().bind("keyup", function() { - // 加载信息 - var value = $(this).val(); - if (value == lastVal) { - return; - } - lastVal = value; - if (value == "") { - $("#colla_suggest_box").empty(); - $("#add_prompt4").hide(); - $("#add_prompt3").hide(); - $("#add_prompt2").hide(); - $("#add_prompt1").show(); - return; - } - Util.ajax({ - url : "/collaboration/get_new_members", - data : { - value : value - }, - success : function(data) { - $("#colla_suggest_box").html(data); - if ($("#colla_suggest_box").find("ul").length > 0) { - $("#add_prompt4").hide(); - $("#add_prompt3").hide(); - $("#add_prompt2").show(); - $("#add_prompt1").hide(); - } else { - $("#add_prompt4").hide(); - $("#add_prompt3").hide(); - $("#add_prompt2").hide(); - $("#add_prompt1").show(); - } - $(".colla_suggest").find("li").unbind().bind("click", - function() { - $("#add_prompt4").hide(); - $("#add_prompt3").hide(); - $("#add_prompt2").show(); - $("#add_prompt1").hide(); - var value = $.trim($("#input_add_colla").val()); - $(".colla_suggest").find("li") - .removeClass("seled"); - $(this).addClass("seled"); - var type = $(this).attr("joinType"); - var target = $(this).attr("target"); - if (type == "user") { - var userName = $(this).attr("username"); - $("#input_add_colla").val(userName); - $("#add_userid").val(target); - } else { - $("#input_add_colla").val(target); - $("#add_userid").val(target); - } - $("#add_type").val(type); - }); - } - }); - }); - }, - doAddCollaboration : function() { - if ($(".colla_suggest").length > 0) { - if ($(".colla_suggest").find(".seled").length == 0) { - $("#add_prompt1").hide(); - $("#add_prompt2").show(); - $("#add_prompt3").hide(); - $("#add_prompt4").hide(); - var top = ($(window).outerHeight() - 104) * 0.5 + 100; - var left = ($(window).outerWidth() - 272) * 0.5; - $("#confirm_dlg").removeClass("newSize").css({ - top : top + "px", - left : left + "px" - }); - $("#confirm_dlg").addClass("newSize").css({ - top : ($(window).outerHeight() - $("#confirm_dlg").height()) - * 0.5 + "px", - left : ($(window).outerWidth() - $("#confirm_dlg").width()) - * 0.5 + "px", - display : "block" - }); - } else { - var imgSrc = $(".colla_suggest").find(".seled").find("img") - .attr("src"); - var userFullName = $("#input_add_colla").val(); - if (userFullName.length > 30) { - userFullName = userFullName.substr(0, 30) + "..."; - } - var target = $("#add_userid").val(); - var role = $("#invit_role").val(); - var type = $("#add_type").val(); - $(".add_new_button") - .find(".designer_button") - .text("<@i18n resource='diagraming.collaboation_sending'/>"); - var target_item = null; - if (type == "email") { - $(".role_list").find(".role_item").each(function() { - if ($(this).attr("type") == type - && $(this).attr("target") == target) { - target_item = $(this); - $(this) - .find(".inviting_") - .text("<@i18n resource='diagraming.collaboation_inviting_again'/>"); - } - }); - } - - var paramOuter = { - type : type, - target : target, - role : role, - chartId : chartId - }; - Util.ajax({ - url : "/collaboration/add", - data : paramOuter, - success : function(data) { - var result = data.result; - if (result == "exists") { - $("#add_prompt2").hide(); - $("#add_prompt1").hide(); - $("#add_prompt4").hide(); - $("#add_prompt3").show(); - } else { - Util.ajax({ - url : "/collaboration/get_colla_role_list", - data : { - chartId : chartId - }, - success : function(data) { - $(".role_list").html(data) - .scrollTop(999); - } - }); - } - $(".add_new_button") - .find(".designer_button") - .text("<@i18n resource='diagraming.collaboation_send_invitation'/>"); - $("#colla_dialog").addClass("_update").css({ - top : ($(window).height() - $("#colla_dialog") - .outerHeight()) - * 0.5 + "px" - }); - if (result != "exists") { - setTimeout(function() { - $("#add_prompt3").hide(); - $("#add_prompt2").hide(); - $("#add_prompt1").hide(); - $("#add_prompt4").show(); - }, 400); - } - setTimeout(function() { - $("#add_prompt3").hide(); - $("#add_prompt2").hide(); - $("#add_prompt4").hide(); - $("#add_prompt1").show(); - $("#input_add_colla").val(""); - $("#colla_suggest_box").html(""); - }, 1000); - } - }); - } - } - }, - deleteCollaRole : function(dom) { - var parent = $(dom).parent(".role_item"); - var collaborationId = parent.attr("collaborationId"); - Util.ajax({ - url : "/collaboration/delete", - data : { - collaborationId : collaborationId - }, - success : function(data) { - if (data.result == "success") - parent.remove(); - } - }); - - $("#colla_dialog").addClass("_update").css({ - top : ($(window).height() - $("#colla_dialog").outerHeight()) * 0.5 - + "px" - }); - }, - changeCollaRole : function(collaborationId, dom) { - Util.ajax({ - url : "/collaboration/set_role", - data : { - collaborationId : collaborationId, - role : $(dom).val() - }, - success : function(data) { - if (data.result == "success") { - $(dom).parent(".given_role") - .find(".change_success").stop().animate({ - "left" : "-38px" - }, 200).delay(400).animate({ - "left" : "0px" - }, 200); - } - } - }); - }, - /** - * 打开图形管理 - */ - showShapesManage : function() { - var $dialog = $("#shapes_dialog").dialog({ - buttons : [{ - text : '确定', - cls : "blue", - handler : UI.saveShapesManage - }, { - text : '关闭', - handler : function() { - $dialog.dialog("close"); - } - }] - }); - $("#shape_manage_list").children("li").unbind().bind("click", - function() { - var chkbox = $(this).find("input"); - var checked = !chkbox.is(":checked"); - chkbox.attr("checked", checked); - cateChanged(chkbox); - }); - $("#shape_manage_list").find("input").unbind().bind("click", - function(e) { - e.stopPropagation(); - cateChanged($(this)); - }); - // .each(function(){ - // var categorys = $(this).val(); - // var arr = categorys.split(","); - // var exists = true; - // for(var i = 0; i < arr.length; i++){ - // var cate = arr[i]; - // if(!CategoryMapping[cate]){ - // //此分类下的图形,没有在当前使用中 - // exists = false; - // break; - // } - // } - // $(this).attr("checked", exists); - // }); - - function cateChanged(chk) { - var value = chk.val(); - var arr = value.split(","); - var chked = chk.is(":checked"); - if (arr.length > 1) { - // 是父级节点 - $("#shape_manage_list").find("input").each(function() { - var cate = $(this).val(); - if (arr.indexOf(cate) >= 0) { - // 是选择父级的子节点 - $(this).attr("checked", chked); - } - }); - } else { - // 选择的是子节点 - $("#shape_manage_list").find(".cate_parent").each(function() { - // 获取所有的父节点,判断子节点是否都全部选中了 - var cates = $(this).val().split(","); - var allChked = true; - for (var i = 0; i < cates.length; i++) { - var cate = cates[i]; - if (!$("#shape_manage_list").find("input[value=" + cate - + "]").is(":checked")) { - allChked = false; - break; - } - } - $(this).attr("checked", allChked); - }); - } - } - }, - /** - * 保存图形管理 - */ - saveShapesManage : function() { - var checked = $("#shape_manage_list") - .find("input:checked:not(.cate_parent)").map(function() { - return $(this).val(); - }).get(); - var a = ""; - var messages = { - categories : checked.join(",") - }; - // //发送消息 - // var msgObj = { - // action: "changeSchema", - // messages: JSON.stringify(messages) - // }; - // CLB.send(msgObj); - Designer.setSchema(checked.join(","), function() { - $("#shapes_dialog").dialog("close"); - }); - }, - /** - * 打开用户菜单 - */ - showUserMenu : function(e) { - e.stopPropagation(); - $("#user_menu").dropdown({ - target : $(".user"), - position : "right", - onSelect : function(item) { - var action = item.attr("ac"); - if (action == "dia") { - location.href = "/diagrams"; - } else if (action == "net") { - location.href = "/network"; - } else if (action == "out") { - location.href = "/login/out"; - } - } - }); - }, - /** - * 打开另存为 - */ - showSaveAs : function() { - $("#saveas_dialog").dlg(); - $("#saveas_title").val($(".diagram_title").text()).select(); - }, - doSaveAs : function() { - if ($("#saveas_title").val().trim() == "") { - $("#saveas_title").focus(); - return; - } - $("#hid_saveas_id").val(chartId); - $("#saveas_form").submit(); - $("#btn_dosaveas").removeAttr("onclick"); - }, - activityNoDlg : function() { - //创建Dialog的DOM,关闭时销毁 - var dialogHTML = ''; - /*计算dialog高度,规则 - 1、最小值340 - 2、每行26px,1条件出现纵向滚动条时(行>8),需要根据高度行数扩大 - 3、最大window.height-40 - */ - //获取当前节点号数组 - // var filterNames = 'timerIntermediateCatchEvent,messageIntermediateCatchEvent,signalIntermediateCatchEvent,messageIntermediateThrowingEvent,signalIntermediateThrowingEvent,compensateIntermediateThrowingEvent,userTask,serviceTask,scriptTask,manualTask,businessRuleTask,sendTask,receiveTask,callActivityCallingProcess,'; - var filterNames = undefined; - var taskList = UI.getTasksList(filterNames); - var dialogHeight = 340; - if (taskList.length > 8) { - dialogHeight = 340 + (taskList.length - 8) * 26 - } - if (dialogHeight > ($(window).height() - 80)) { - dialogHeight = ($(window).height() - 80); - } - dialogHTML += ''; - $(document.body).append(dialogHTML); - //显示Dialog - $("#activityNoDialog").dialog({ - onClose: function () { - $('#activityNoDialog').remove(); - $('#row-drag-obj').remove();//grid拖动时产生的行,鼠标拖动到document外时,该div一直显示 - }, - buttons: [ - { - text: '确定', cls: "blue", - handler: function () { - if (activityNoArr.length > 0) { - //将节点号重新设置 - var allRows = activityNoGrid.awsGrid('getAllRows'); - for (var shapeId in Model.define.elements) { - var shape = Model.getShapeById(shapeId); - for(var x = 0; x < allRows.length; x++) { - var obj = allRows[x]; - if(obj.id == shape.id) { - if (shape.dataAttributes != undefined) { - for (var i = 0; i < shape.dataAttributes.length; i++) { - for (var i = 0; i < shape.dataAttributes.length; i++) { - var attrArr = shape.dataAttributes[i]; - if (attrArr.attributesJsonArray && attrArr.attributesJsonArray.length > 0) { - for (var j = 0; j < attrArr.attributesJsonArray.length; j++) { - var attr = attrArr.attributesJsonArray[j]; - if (attr.id == 'number') { - attr.value = parseInt(obj.no); - break; - } - } - break; - } - } - } - } - } - } - } - if (isAutoSave == "0" ){ - $("#saving_tip").css("color", "rgb(255, 0, 0)"); - $("#saving_tip").text("文件已修改,未保存"); - } - } - $("#activityNoDialog").dialog('close'); - } - }, - { - text: '取消', handler: function () { - $("#activityNoDialog").dialog('close'); - } - } - ] - }); - var activityNoArr = [];//JSON数组 - for (var i = 0; i < taskList.length; i++) { - var task = taskList[i]; - var activityNoObj = {}; - activityNoObj.id = task.id; - if (task.text) { - activityNoObj.name = task.text; - } else { - activityNoObj.name = '(无名称)' + task.title; - } - activityNoObj.no = task.orderIndex; - activityNoArr[i] = activityNoObj; - } - if (activityNoArr.length == 0) { - $('#activityNoGrid').height(dialogHeight - 100); - $('#activityNoGrid').width(317); - $('#activityNoAlert').remove(); - $('#activityNoGrid').append($('
      '+ - '
      '+ - ''+ - '不支持编号排序'+ - '画布没有形状或者形状没有编号属性'+ - '
      '+ - '
      ')); - awsuiMessagePage(); - return; - } - //渲染Grid - var activityNoGridOptions = { - width: 317, - height: dialogHeight - 100, - flexWidth: false, - flexHeight: false, - resizable: false, - selectionModel: { - type: "none", - model: "single" - }, - scrollModel: { - vertical: true, - horizontal: false - }, - bottomVisible: false, - rowDrag: true - }; - activityNoGridOptions.colModel = [ - {title: "名称", width: 200, align: 'left', dataType: 'string', dataIndx: 'name', resizable: false, sortable: false}, - {title: "节点号", width: 80, align: 'center', dataType: 'integer', dataIndx: 'no', resizable: false, sortable: false} - ]; - activityNoGridOptions.dataModel = { - data: activityNoArr, - location: "local", - sorting: "local", - sortIndx: "no", - sortDir: "up" - }; - var activityNoGrid = $("#activityNoGrid").awsGrid(activityNoGridOptions); - activityNoGrid.awsGrid('option', 'rowDragCallback', function (source, target) { - return true; - }); - activityNoGrid.awsGrid('option', 'rowDragSuccessCallback', function (source, target) { - //重新排列序号 - var allRows = activityNoGrid.awsGrid('getAllRows'); - for (var i = 0; i < allRows.length; i++) { - allRows[i].no = (i + 1); - } - activityNoGrid.awsGrid('refreshDataAndView'); - }); - }, - getTasksList: function (filterNames) { - var filterNode = []; - var nodes = Model.define.elements; - if (filterNames == undefined) { - return UI.getALLTasksList(); - } - }, - getALLTasksList: function () { - var filterNode = []; - for (var shapeId in Model.define.elements) { - var shape = Model.getShapeById(shapeId); - if (shape.dataAttributes != undefined) { - for (var i = 0; i < shape.dataAttributes.length; i++) { - for (var i = 0; i < shape.dataAttributes.length; i++) { - var attrArr = shape.dataAttributes[i]; - if (attrArr.attributesJsonArray && attrArr.attributesJsonArray.length > 0) { - for (var j = 0; j < attrArr.attributesJsonArray.length; j++) { - var attr = attrArr.attributesJsonArray[j]; - if (attr.id == 'number') { - var tempNumber = 0; - var number = attr.value; - if(typeof number == 'string') number = number.replace(/^\s+|\s+$/g,""); - if(!isNaN(number) && number != '') { - tempNumber = number; - } - var obj = {}; - obj.text = shape.text; - obj.id = shapeId; - obj.orderIndex = tempNumber; - filterNode.push(obj); - break; - } - } - break; - } - } - } - } - } - return filterNode; - }, - batchReplace: function() { - if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") { - if (editable) { - $.simpleAlert('页面中有未保存的内容,请先保存'); - return; - } - } - // 打开批量处理框 - initWizardByDesinger(); - } -}; - -/** - * 右侧的Dock控件 - * - * @type {} - */ -var Dock = { - init : function() { - var layoutW = $("#designer_layout").width(); - var viewW = $("#layout_block").width(); - // 总宽度减去可视区域的宽度,得到滚动条宽度 - var navRight = layoutW - viewW; - $("#dock").css("right", navRight); - var dockRight = navRight + $("#dock").outerWidth() - 1; - $(".dock_view").css("right", dockRight); - if ($("#demo_signup").length) { - var signupH = $("#demo_signup").outerHeight(); - $("#dock").css("top", signupH); - $(".dock_view").css("top", signupH + 10); - } - $(".ico_dock_collapse").bind("click", function() { - $(".dock_view").hide(); - $(".dock_buttons").children().removeClass("selected"); - if (Dock.currentView == "history") { - Dock.closeHistory(); - } - Dock.currentView = ""; - }); - $(window).bind("resize.dock", function() { - if (Dock.currentView == "attribute") { - Dock.fitAttrList(); - } - }); - // 缩放 - $("#dock_zoom").spinner({ - min : 50, - max : 200, - unit : "%", - step : 10, - onChange : function(val) { - Designer.setZoomScale(val / 100); - } - }); - // 线条颜色 - $("#dock_line_color").colorButton({ - onSelect : function(color) { - Designer.setLineStyle({ - lineColor : color - }); - } - }); - // 线条类型 - $("#dock_line_style").button({ - onMousedown : function() { - $("#line_style_list").dropdown({ - target : $("#dock_line_style"), - onSelect : function(item) { - var lineStyle = item.attr("line"); - Designer.setLineStyle({ - lineStyle : lineStyle - }); - var cls = item.children("div").attr("class"); - $("#dock_line_style").children(".linestyle").attr( - "class", cls); - } - }); - var style = Utils.getSelected()[0].lineStyle.lineStyle; - var item = $("#line_style_list").children("li[line=" + style - + "]"); - $("#line_style_list").dropdown("select", item); - } - }); - // 线条宽度 - $("#dock_line_width").spinner({ - min : 0, - max : 10, - unit : "px", - step : 1, - onChange : function(val) { - Designer.setLineStyle({ - lineWidth : val - }); - } - }); - // 填充类型 - $("#dock_fill_type").button({ - onMousedown : function() { - $("#dock_fill_list").dropdown({ - target : $("#dock_fill_type"), - onSelect : function(item) { - var type = item.attr("ty"); - $("#dock_fill_type").button("setText", - item.text()); - if (type == "image") { - UI.showImageSelect(function(fileId, w, h) { - Designer.setFillStyle({ - type : "image", - fileId : fileId, - imageW : w, - imageH : h - }); - }); - } else { - Designer.setFillStyle({ - type : type - }); - var shapeIds = Utils.getSelectedShapeIds(); - var shape = Model.getShapeById(shapeIds[0]); - Dock.setFillStyle(shape.fillStyle); - } - } - }); - var type = $("#dock_fill_type").text(); - $("#dock_fill_list").children().each(function() { - if ($(this).text() == type) { - $("#dock_fill_list") - .dropdown("select", $(this)); - return false; - } - }); - } - }); - // 填充颜色 - $("#fill_solid_btn").colorButton({ - onSelect : function(color) { - Designer.setFillStyle({ - color : color - }); - } - }); - // 渐变开始颜色 - $("#fill_gradient_begin").colorButton({ - onSelect : function(color) { - Designer.setFillStyle({ - beginColor : color - }); - $("#fill_gradient_begin").attr("c", color); - } - }); - // 渐变结束颜色 - $("#fill_gradient_end").colorButton({ - onSelect : function(color) { - Designer.setFillStyle({ - endColor : color - }); - $("#fill_gradient_end").attr("c", color) - } - }); - // 渐变颜色交换 - $("#gradient_swap").button({ - onClick : function() { - var begin = $("#fill_gradient_begin").attr("c"); - var end = $("#fill_gradient_end").attr("c"); - $("#fill_gradient_begin").attr("c", end).colorButton( - "setColor", end); - $("#fill_gradient_end").attr("c", begin).colorButton( - "setColor", begin); - Designer.setFillStyle({ - beginColor : end, - endColor : begin - }); - } - }); - // 渐变类型 - $("#gradient_type").button({ - onMousedown : function() { - $("#gradient_type_list").dropdown({ - target : $("#gradient_type"), - onSelect : function(item) { - var type = item.attr("ty"); - $("#gradient_type").button("setText", item.text()); - Designer.setFillStyle({ - gradientType : type - }); - $(".gradient_details").hide(); - $("#gradient_type_" + type).show(); - var shapeIds = Utils.getSelectedShapeIds(); - var shape = Model.getShapeById(shapeIds[0]); - var fillStyle = shape.fillStyle; - if (type == "linear") { - $("#gradient_angle").spinner( - "setValue", - Math.round(fillStyle.angle / Math.PI * 180) - + "°"); - } else { - $("#gradient_radius").spinner("setValue", - Math.round(fillStyle.radius * 100) + "%"); - } - } - }); - var type = $("#gradient_type").text().trim(); - $("#gradient_type_list").children().each(function() { - if ($(this).text() == type) { - $("#gradient_type_list").dropdown("select", - $(this)); - return false; - } - }); - } - }); - // 线性渐变角度 - $("#gradient_angle").spinner({ - min : 0, - max : 360, - unit : "°", - step : 15, - onChange : function(val) { - var angle = val / 180 * Math.PI; - Designer.setFillStyle({ - angle : angle - }); - } - }); - // 径向渐变半径 - $("#gradient_radius").spinner({ - min : 0, - max : 100, - unit : "%", - step : 5, - onChange : function(val) { - Designer.setFillStyle({ - radius : val / 100 - }); - } - }); - // 改变背景图片 - $("#fill_change_img").button({ - onClick : function() { - UI.showImageSelect(function(fileId, w, h) { - Designer.setFillStyle({ - type : "image", - fileId : fileId, - imageW : w, - imageH : h - }); - }); - } - }); - // 背景图片显示 - $("#fill_img_display").button({ - onMousedown : function() { - $("#img_display_list").dropdown({ - target : $("#fill_img_display"), - onSelect : function(item) { - var type = item.attr("ty"); - $("#fill_img_display").button("setText", - item.text()); - Designer.setFillStyle({ - display : type - }); - } - }); - } - }); - // 透明度 - $("#spinner_opacity").spinner({ - min : 0, - max : 100, - unit : "%", - step : 5, - onChange : function(val) { - Designer.setShapeStyle({ - alpha : val / 100 - }); - } - }); - // X坐标 - $("#dock_metric_x").spinner({ - min : -800, - unit : "px", - step : 5, - onChange : function(val) { - Designer.setShapeProps({ - x : val - }); - } - }); - $("#dock_metric_x").spinner("setValue", "0px"); - // 宽度 - $("#dock_metric_w").spinner({ - min : 20, - unit : "px", - step : 5, - onChange : function(val) { - Designer.setShapeProps({ - w : val - }); - } - }); - // Y坐标 - $("#dock_metric_y").spinner({ - min : -800, - unit : "px", - step : 5, - onChange : function(val) { - Designer.setShapeProps({ - y : val - }); - } - }); - $("#dock_metric_y").spinner("setValue", "0px"); - // 高度 - $("#dock_metric_h").spinner({ - min : 20, - unit : "px", - step : 5, - onChange : function(val) { - Designer.setShapeProps({ - h : val - }); - } - }); - // 角度 - $("#dock_metric_angle").spinner({ - min : 0, - max : 360, - unit : "°", - step : 15, - onChange : function(val) { - var angle = val / 180 * Math.PI; - Designer.setShapeProps({ - angle : angle - }); - } - }); - // 画布尺寸 - $("#dock_page_size").button({ - onMousedown : function() { - $("#page_size_list").dropdown({ - target : $("#dock_page_size"), - onSelect : function(item) { - var w = parseInt(item.attr("w")); - var h = parseInt(item.attr("h")); - Designer.setPageStyle({ - width : w, - height : h - }); - $("#dock_page_size").button("setText", - item.text()); - } - }); - var item = $("#page_size_list").children("li[w=" - + Model.define.page.width + "][h=" - + Model.define.page.height + "]"); - if (item.length > 0) { - $("#page_size_list").dropdown("select", item); - } else { - $("#page_size_list").dropdown("select", - $("#dock_size_custom")); - } - $("#dock_size_w").spinner("setValue", - Model.define.page.width + "px"); - $("#dock_size_h").spinner("setValue", - Model.define.page.height + "px"); - } - }); - $("#dock_size_w").spinner({ - min : 200, - unit : "px", - step : 100, - onChange : function(val) { - Designer.setPageStyle({ - width : val - }); - } - }); - $("#dock_size_h").spinner({ - min : 200, - unit : "px", - step : 100, - onChange : function(val) { - Designer.setPageStyle({ - height : val - }); - } - }); - // 页面边距 - $("#dock_page_padding").button({ - onMousedown : function() { - $("#page_padding_list").dropdown({ - target : $("#dock_page_padding"), - onSelect : function(item) { - var p = parseInt(item.attr("p")); - Designer.setPageStyle({ - padding : p - }) - $("#dock_page_padding").button("setText", - item.text()); - } - }); - var item = $("#page_padding_list").children("li[p=" - + Model.define.page.padding + "]"); - $("#page_padding_list").dropdown("select", item); - } - }); - // 画布背景颜色 - $("#dock_page_color").colorButton({ - position : "center", - onSelect : function(color) { - Designer.setPageStyle({ - backgroundColor : color - }); - } - }); - // 是否显示网格 - $("#dock_page_showgrid").bind("change", function() { - var showGrid = $(this).is(":checked"); - Designer.setPageStyle({ - showGrid : showGrid - }); - if (showGrid) { - $("#dock_gridsize_box").show(); - } else { - $("#dock_gridsize_box").hide(); - } - }); - // 网格大小 - $("#dock_page_gridsize").button({ - onMousedown : function() { - $("#page_gridsize_list").dropdown({ - target : $("#dock_page_gridsize"), - onSelect : function(item) { - var s = parseInt(item.attr("s")); - Designer.setPageStyle({ - gridSize : s - }) - $("#dock_page_gridsize").button("setText", item.text()); - } - }); - var item = $("#page_gridsize_list").children("li[s=" - + Model.define.page.gridSize + "]"); - $("#page_gridsize_list").dropdown("select", item); - } - }); - // 播放速度 - $("#spinner_play_speed").spinner({ - min : 1, - max : 30, - unit : "s", - step : 1, - value : 5, - onChange : function(val) { - - } - }); - $("#spinner_play_speed").spinner("setValue", "2s"); - // 版本播放 - $("#btn_history_play").button({ - onClick : function() { - if ($("#btn_history_play").children() - .hasClass("ico_pause")) { - Dock.pauseVersions(); - } else { - Dock.playVersions(); - } - } - }); - $("#btn_history_restore").button({ - onClick : function() { - Dock.restoreVersion(); - } - }); - }, - /** - * 当前Dock窗口 - * - * @type {String} - */ - currentView : "", - /** - * 打开一个Dock窗口 - * - * @param {} - * name - */ - showView : function(name) { - if ($("#dock_btn_" + name).button("isDisabled")) { - return; - } - $(".dock_view").hide(); - $(".dock_view_" + name).show(); - $(".dock_buttons").children().removeClass("selected"); - $("#dock_btn_" + name).addClass("selected"); - if (Dock.currentView == "history" && name != "history") { - Dock.closeHistory(); - } - this.currentView = name; - this.update(true); - }, - /** - * 设置Dock的填充样式 - * - * @param {} - * fillStyle - */ - setFillStyle : function(fillStyle) { - $("#dock_fill_type").button( - "setText", - $("#dock_fill_list").children("li[ty=" + fillStyle.type + "]") - .text()); - $(".fill_detail").hide(); - if (fillStyle.type == "solid") { - $(".fill_detail_solid").show(); - $("#fill_solid_btn").colorButton("setColor", fillStyle.color); - } else if (fillStyle.type == "gradient") { - $(".fill_detail_gradient").show(); - // 渐变颜色 - $("#fill_gradient_begin").attr("c", fillStyle.beginColor) - .colorButton("setColor", fillStyle.beginColor); - $("#fill_gradient_end").attr("c", fillStyle.endColor).colorButton( - "setColor", fillStyle.endColor); - // 渐变类型 - $("#gradient_type").button( - "setText", - $("#gradient_type_list").children("li[ty=" - + fillStyle.gradientType + "]").text()); - $(".gradient_details").hide(); - if (fillStyle.gradientType == "linear") { - $("#gradient_type_linear").show(); - $("#gradient_angle").spinner("setValue", - Math.round(fillStyle.angle / Math.PI * 180) + "°"); - } else { - $("#gradient_type_radial").show(); - $("#gradient_radius").spinner("setValue", - Math.round(fillStyle.radius * 100) + "%"); - } - } else if (fillStyle.type == "image") { - $(".fill_detail_image").show(); - var display = "fill"; - if (fillStyle.display) { - display = fillStyle.display; - } - $("#fill_img_display").button( - "setText", - $("#img_display_list").children("li[ty=" + display + "]") - .text()); - } - }, - /** - * 更新Dock - */ - update : function(drawNav) { - if (this.currentView == "portalAttrShow" || this.currentView == "portalDescShow" || this.currentView == "portalFileShow") { - changeArributeByShape(); - } - if (this.currentView == "navigator") { - if (drawNav) { - Navigator.draw(); - } - $("#dock_zoom").spinner("setValue", - Math.round(Designer.config.scale * 100) + "%"); - } else if (this.currentView == "graphic") { - var selectedIds = Utils.getSelectedIds(); - var count = selectedIds.length; - var shapeIds = Utils.getSelectedShapeIds(); - var shapeCount = shapeIds.length; - if (count == 0) { - $("#dock_line_color").button("disable"); - $("#dock_line_style").button("disable"); - $("#dock_line_width").button("disable"); - } else { - $("#dock_line_color").button("enable"); - $("#dock_line_style").button("enable"); - $("#dock_line_width").button("enable"); - var shape = Model.getShapeById(selectedIds[0]); - $("#dock_line_color").colorButton("setColor", - shape.lineStyle.lineColor); - var lineStyleCls = $("#line_style_list").children("li[line=" - + shape.lineStyle.lineStyle + "]").children() - .attr("class"); - $("#dock_line_style").children(".linestyle").attr("class", - lineStyleCls); - $("#dock_line_width").spinner("setValue", - shape.lineStyle.lineWidth + "px"); - } - if (shapeCount == 0) { - $("#dock_fill_type").button("disable"); - $("#spinner_opacity").button("disable"); - Dock.setFillStyle({ - type : "none" - }); - } else { - $("#dock_fill_type").button("enable"); - $("#spinner_opacity").button("enable"); - var shape = Model.getShapeById(shapeIds[0]); - Dock.setFillStyle(shape.fillStyle); - $("#spinner_opacity").spinner("setValue", - Math.round(shape.shapeStyle.alpha / 1 * 100) + "%"); - } - } else if (this.currentView == "metric") { - var shapeIds = Utils.getSelectedShapeIds(); - var shapeCount = shapeIds.length; - if (shapeCount == 0) { - $("#dock_metric_x").button("disable"); - $("#dock_metric_w").button("disable"); - $("#dock_metric_y").button("disable"); - $("#dock_metric_h").button("disable"); - $("#dock_metric_angle").button("disable"); - } else { - var shape = Model.getShapeById(shapeIds[0]); - $("#dock_metric_x").button("enable").spinner("setValue", - Math.round(shape.props.x) + "px"); - $("#dock_metric_w").button("enable").spinner("setValue", - Math.round(shape.props.w) + "px"); - $("#dock_metric_y").button("enable").spinner("setValue", - Math.round(shape.props.y) + "px"); - $("#dock_metric_h").button("enable").spinner("setValue", - Math.round(shape.props.h) + "px"); - $("#dock_metric_angle").button("enable").spinner("setValue", - Math.round(shape.props.angle / Math.PI * 180) + "°"); - } - } else if (this.currentView == "page") { - var page = Model.define.page; - var w = page.width; - var h = page.height; - var sizeItem = $("#page_size_list").children("li[w=" + w + "][h=" - + h + "]"); - var sizeText = ""; - if (sizeItem.length > 0) { - sizeText = sizeItem.text(); - } else { - sizeText = $("#dock_size_custom").text(); - } - $("#dock_page_size").button("setText", sizeText); - $("#dock_page_padding").button("setText", page.padding + "px"); - $("#dock_page_color").colorButton("setColor", page.backgroundColor); - $("#dock_page_showgrid").attr("checked", page.showGrid); - if (page.showGrid) { - $("#dock_gridsize_box").show(); - } else { - $("#dock_gridsize_box").hide(); - } - var gridText = ""; - var gridItem = $("#page_gridsize_list").children("li[s=" - + page.gridSize + "]"); - if (gridItem.length > 0) { - var gridText = gridItem.text(); - } - $("#dock_page_gridsize").button("setText", gridText); - } else if (this.currentView == "attribute") { - if (!inputUpdate) {// input类型的属性值更新时不重绘所有属性 - changeArributeByShape(); - } - if(role == "viewer") { - $("#dock_page_attribute table input").prop("disabled", true); - $("#tagContent1 table input, #tagContent1 table textarea").prop("disabled", true); - } - } else if (this.currentView == "message") { - $.ajax({ - url: "./jd?sid=" + $("#sid").val() - + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_commentlist" - + "&repositoryId=" + ruuid + "&openAppType=" + openAppType, - success: function(msg){ - var html = ""; - var array; - if (typeof(msg) == "string") { - array = eval('(' + msg + ')').msg; - } else { - array = msg.msg; - } - if (typeof(array) == "string") { - array = eval('(' + array + ')'); - } - for (var i = 0; i < array.length; i++) { - var obj = array[i]; - html += getHtml(obj); - } - $("#messageContent").html(html); - } - }); - } else if (this.currentView == "publish") { - $.ajax({ - url: "./jd?sid=" + $("#sid").val() - + "&cmd=com.actionsoft.apps.coe.pal_publish_history_of_repository&wsId=" + $("#wsId").val() - + "&repositoryId=" + ruuid, - success: function(msg){ - var array; - if (typeof(msg) == "string") { - array = eval('(' + msg + ')').msg; - } else { - array = msg.msg; - } - if (typeof(array) == 'string') { - array = eval('(' + array + ')'); - } - var html = ""; - if (array != null && array.length > 0) { - for (var i = 0; i < array.length; i++) { - var data = array[i]; - var type = data.publishType; - var style = ""; - var info = ""; - if (type == "N") { - style = "green"; - info = "新发布"; - } else if (type == "C") { - style = "blue"; - info = "变更"; - } else if (type == "S") { - style = "red"; - info = "停用"; - } - var clickHtml = ""; - if (data.plId != undefined) { - clickHtml = " style='cursor: pointer;' onclick=\"openFileLink('" + data.plId + "', '_seft', '" + data.plName + "')\""; - } - html += "
      " - + " " - + " " - + " " - + "
      "; - } - - } else { - html = "
      暂无发布历史
      "; - } - $("#sidePublishListDiv article").html(html); - } - }); - } else if (this.currentView == "link") { - $.ajax({ - url: "./jd?sid=" + $("#sid").val() - + "&cmd=com.actionsoft.apps.coe.pal_link_of_repository&wsId=" + $("#wsId").val() - + "&plId=" + ruuid, - success: function(r){ - var links = r.data.links; - var customLinks = r.data.customLInks; - var html = ""; - var flag1 = false; - var flag2 = false; - if (links != null && links.length > 0) { - html += '

      文件链接

      '; - for (var i = 0; i < links.length; i++) { - html += ''; - } - } else { - flag1 = true; - } - if (customLinks != null && customLinks.length > 0){ - html += '

      自定义链接

      '; - html += ''; - } else { - flag2 = true; - } - if (flag1 && flag2) { - html = "
      暂无链接
      "; - } - $("#linkContent").empty().html(html); - } - }); - } - else if(this.currentView == 'diff') { - // var html = "
      暂无版本差异
      "; - var html = '' - $.ajax({ - url: "./jd?sid=" + $("#sid").val() - + "&cmd=com.actionsoft.apps.coe.pal_repository_model_version_diff_query&wsId=" + $("#wsId").val() - + "&id=" + ruuid, - success: function (ro) { - // console.log("历史差异结果: " + JSON.stringify(ro)) - if (ro.result == "ok") { - var diffContent = ro.data; - for (var i = 0; i < diffContent.length; i++) { - var diffCount = 0 - var content = diffContent[i].updateContent - var diffListHtml = '' - for (var j = 0; j < content.length; j++) { - var diffDetailHtml = '' - var listDetail = content[j].detail - if (listDetail.length == 0) { - diffCount += 1 - } - for (var k = 0; k < listDetail.length; k++) { - diffCount += 1 - diffDetailHtml += '
      ' + '·' + listDetail[k] + '
      ' - } - diffListHtml += '
      ' + content[j].title + '
      ' - + '
      ' + diffDetailHtml + '
      ' - - } - html += '' - + '' + diffContent[i].versionName + '' - + '' + diffContent[i].updateTime + '' + '(' + diffCount + '处修改)' + '' + '' - + '' - + '' - + '' - + '' + diffListHtml + '' - + '' - - } - $("#diffTable").empty().html(html) - } else { - html = '' - + ro.msg - + '' - $("#diffTable").empty().html(html) - } - } - }); - } - if (this.currentView == "history") { - if (drawNav && Dock.historyVersions == null) { - this.loadHistorys(); - } - } - }, - /** - * 历史版本暂存 - * - * @type {} - */ - historyVersions : null, - /** - * 加载历史版本 - */ - loadHistorys : function() {/* - if (chartId == "") { - $("#history_container") - .html("
      <@i18n resource='diagraming.demo.nohistory'/>
      ") - return; - } - $.ajax({ - url : "/diagraming/history", - data : { - chartId : chartId - }, - success : function(data) { - Dock.historyVersions = data; - if (data.versions.length == 0) { - $("#history_container") - .html('
      <@i18n resource="diagraming.nohistory"/>
      '); - } else { - $("#history_container") - .html('
        '); - var users = data.users; - for (var i = 0; i < data.versions.length; i++) { - var v = data.versions[i]; - var newVersion = $('
      • ' + v.updateTime - + '
      • ') - .appendTo($("#history_versions")); - var nameContainer = newVersion - .children(".version_name"); - for (var j = 0; j < v.userIds.length; j++) { - var userId = v.userIds[j]; - nameContainer.append("
        " + users[userId] - + "
        "); - } - var remarkContainer = $("") - .appendTo(newVersion); - if (v.remark) { - remarkContainer.find(".remark_text").text(v.remark); - } - remarkContainer - .append("") - } - Dock.resetVersions(); - } - } - }); - */}, - /** - * 重置版本历史 - */ - resetVersions : function() { - $("#history_versions").children("li").unbind().bind("click", - function() { - if (Dock.playingTimeout != null) { - return; - } - if ($(this).hasClass("selected")) { - Dock.closeHistory(); - } else { - $("#history_versions").children(".selected") - .removeClass("selected"); - $(this).addClass("selected"); - var defId = $(this).attr("def"); - Dock.showHistoryVersion(defId); - } - var current = $("#history_versions").children(".selected"); - if (current.length != 0 && current.attr("ind") != "0") { - $("#spinner_play_speed").button("enable"); - $("#btn_history_play").button("enable"); - $("#btn_history_restore").button("enable"); - } else { - $("#spinner_play_speed").button("disable"); - $("#btn_history_play").button("disable"); - $("#btn_history_restore").button("disable"); - } - }); - $("#history_versions").height("auto"); - var top = $("#history_versions").offset().top; - var bottom = top + $("#history_versions").height() + 75; - if (bottom > $(window).height()) { - var height = $(window).height() - top - 75; - if (height < 140) { - height = 140; - } - $("#history_versions").height(height); - } else { - $("#history_versions").height("auto"); - } - }, - /** - * 编辑版本注释 - * - * @param {} - * event - */ - editHistoryRemark : function(event, versionId) { - event.stopPropagation(); - var versionDom = $("#history_versions").children("li[vid=" + versionId - + "]"); - versionDom.find(".remark_container").hide(); - var currentRemark = versionDom.find(".remark_text").text(); - var editContainer = versionDom.find(".edit_container"); - editContainer.show(); - editContainer.children("textarea").val(currentRemark).select(); - editContainer.children(".save").bind("click", function(e) { - e.stopPropagation(); - var newRemark = editContainer.children("textarea").val(); - versionDom.find(".remark_text").text(newRemark); - versionDom.find(".remark_container").show(); - editContainer.hide(); - if (newRemark != currentRemark) { - CLB.send({ - action : "versionRemark", - remark : newRemark, - versionId : versionId - }); - } - }); - editContainer.children(".cancel").bind("click", function(e) { - e.stopPropagation(); - Dock.cancelHistoryRemark(); - }); - }, - /** - * 取消版本注释的编辑 - */ - cancelHistoryRemark : function() { - $(".remark_container").show(); - $(".edit_container").hide(); - }, - /** - * 展示历史版本 - */ - showHistoryVersion : function(defId) { - $("#spinner_play_speed").button("disable"); - $("#btn_history_play").button("disable"); - $("#btn_history_restore").button("disable"); - Dock.cancelHistoryRemark(); - $.ajax({ - url : "/diagraming/getdefinition", - data : { - definitionId : defId - }, - success : function(data) { - Dock.openHistory(data.definition); - if ($("#history_versions").children(".selected").attr("ind") != "0") { - $("#spinner_play_speed").button("enable"); - $("#btn_history_play").button("enable"); - $("#btn_history_restore").button("enable"); - } - } - }); - }, - /** - * 播放版本历史 - */ - playVersions : function() { - var current = $("#history_versions").children(".selected"); - // if(current.length == 0){ - // return; - // } - var index = parseInt(current.attr("ind")); - Dock.playOneVersion(index--, 0); - $("#btn_history_play").children().attr("class", "ico ico_pause"); - $("#btn_history_play").attr("title", "暂停").trigger("mouseenter"); - $("#btn_history_restore").button("disable"); - }, - /** - * 终止播放 - */ - pauseVersions : function() { - if (this.playingTimeout) { - clearTimeout(this.playingTimeout); - } - this.playingTimeout = null; - $("#btn_history_play").children().attr("class", "ico ico_play"); - $("#btn_history_play").attr("title", "从此版本播放"); - $(".ico_playing").remove(); - var current = $("#history_versions").children(".selected"); - $("#history_versions").children(".playing").removeClass("playing"); - if (current.length != 0 && current.attr("ind") != "0") { - $("#spinner_play_speed").button("enable"); - $("#btn_history_play").button("enable"); - $("#btn_history_restore").button("enable"); - } else { - $("#spinner_play_speed").button("disable"); - $("#btn_history_play").button("disable"); - $("#btn_history_restore").button("disable"); - } - }, - playingTimeout : null, - /** - * 播放一个版本 - */ - playOneVersion : function(index, msgIndex) { - var current = $("#history_versions").children("li[ind=" + index + "]"); - $("#history_versions").children(".selected").removeClass("selected"); - current.addClass("selected").addClass("playing"); - $(".ico_playing").remove(); - current.append("
        "); - - var version = Dock.historyVersions.versions[index]; - var messageStr = version.messages[msgIndex]; - var messages = JSON.parse(messageStr); - MessageSource.receive(messages); - var top = current.position().top; - if (top < 0) { - $("#history_versions").scrollTop($("#history_versions").scrollTop() - + top); - } - var time = $("#spinner_play_speed").spinner("getValue") * 1000; - if (index == 0 && msgIndex == version.messages.length - 1) { - this.pauseVersions(); - } else { - if (msgIndex < version.messages.length - 1) { - msgIndex++; - } else { - index = index - 1; - msgIndex = 0; - } - this.playingTimeout = setTimeout(function() { - Dock.playOneVersion(index, msgIndex); - }, time); - } - - }, - currentDefinition : null, - /** - * 打开一个历史版本 - */ - openHistory : function(definition) { - if (this.currentDefinition == null) { - this.currentDefinition = $.extend(true, {}, Model.define); - } - Utils.unselect(); - Designer.open(definition); - // 取消快捷键 - Designer.hotkey.cancel(); - Designer.op.cancel(); - $("#menu_bar").children().addClass("readonly"); - $(".diagram_title").addClass("readonly"); - $(".dock_buttons").children().addClass("disabled"); - $("#dock_btn_history").removeClass("disabled"); - $(".panel_box").addClass("readonly"); - // 中止监听 - CLB.stopListen(); - }, - /** - * 关闭历史版本 - */ - closeHistory : function() { - if (this.currentDefinition != null) { - Designer.open(this.currentDefinition); - this.currentDefinition = null; - this.activeOperation(); - } - }, - /** - * 激活操作 - */ - activeOperation : function() { - // 重新初始化快捷键 - Designer.hotkey.init(); - Designer.op.init(); - $("#menu_bar").children().removeClass("readonly"); - $(".diagram_title").removeClass("readonly"); - $(".dock_buttons").children().removeClass("disabled"); - $("#dock_btn_history").removeClass("disabled"); - $(".panel_box").removeClass("readonly"); - $("#history_versions").children(".selected").removeClass("selected"); - // 继续监听 - CLB.listen(); - Dock.loadHistorys(); - }, - /** - * 恢复版本 - */ - restoreVersion : function() { - var selected = $("#history_versions").children(".selected"); - if (selected.length) { - MessageSource.beginBatch(); - var elements = Dock.currentDefinition.elements; - // 删除当前的所有 - var removed = []; - if (elements) { - for (var id in elements) { - removed.push(elements[id]); - } - } - MessageSource.send("remove", removed); - // 更新画布 - var updatePageMsg = { - page : Utils.copy(Dock.currentDefinition.page), - update : Utils.copy(Model.define.page) - }; - MessageSource.send("updatePage", updatePageMsg); - // 添加新图形 - var newElements = Model.define.elements; - var added = []; - if (newElements) { - for (var id in newElements) { - added.push(newElements[id]); - } - } - MessageSource.send("create", added); - MessageSource.commit(); - Dock.activeOperation(); - } - }, - /** - * 设置数据属性列表 - */ - setAttributeList : function() { - var selectedIds = Utils.getSelectedIds(); - var shape = Model.getShapeById(selectedIds[0]); - $(".clearfix").empty(); - if (shape.dataAttributes) { - for (var i = 0; i < shape.dataAttributes.length; i++) { - var attr = shape.dataAttributes[i]; - var typeText = $("#attr_add_type").children("option[value=" - + attr.type + "]").text(); - var item = $("
      • " + attr.name - + "
        " + typeText - + "
        " + attr.value - + "
      • ") - .appendTo($(".attr_list")); - if (attr.category != "default") { - item.append("
        "); - } - } - } - this.fitAttrList(); - }, - /** - * 让数据属性列表适应 - */ - fitAttrList : function() { - var scroll = $("#tagContent").scrollTop(); - $("#tagContent").height("auto"); - var top = $("#tagContent").offset().top; - var bottom = top + $(".clearfix").height() + 10; - if (bottom > $(window).height()) { - var height = $(window).height() - top - 10; - if (height < 140) { - height = 140; - } - $("#tagContent").height(height); - } else { - $("#tagContent").height("auto"); - } - $("#tagContent").scrollTop(scroll); - }, - /** - * 打开数据属性添加 - */ - showAttrAdd : function() { - $("#attr_add_btn").hide(); - $(".attr_add_items").show(); - $("#attr_add_name").val("").focus(); - $("#attr_add_type").val("string"); - $("#attr_add_type").unbind().bind("change", function() { - Dock.setAttrValueInput(null, $(this).val()); - }); - Dock.setAttrValueInput(null, "string"); - this.fitAttrList(); - }, - /** - * 保存数据属性添加 - */ - saveAttrAdd : function() { - var name = $("#attr_add_name").val(); - if (name == "") { - $("#attr_add_name").focus(); - return; - } - var type = $("#attr_add_type").val(); - var value = $("#attr_add_value_arera").children().val(); - var newAttr = { - name : name, - type : type, - value : value - }; - Designer.addDataAttribute(newAttr); - this.setAttributeList(); - // 初始化添加区域 - this.showAttrAdd(); - }, - /** - * 取消数据属性添加 - */ - cancelAttrAdd : function() { - $("#attr_add_btn").show(); - $(".attr_add_items").hide(); - this.fitAttrList(); - }, - /** - * 编辑数据属性 - * - * @param {} - * attrId - */ - editAttr : function(attrId) { - var item = $(".attr_item_" + attrId); - if (item.hasClass("attr_editing")) { - return; - } - if ($(".attr_editing").length > 0) { - var editingId = $(".attr_editing").attr("id"); - this.saveAttrEdit(editingId); - } - item = $(".attr_item_" + attrId); - item.addClass("attr_editing"); - var attr = Designer.getDataAttrById(attrId); - // 属性值输入 - var input = this.setAttrValueInput(attr, attr.type); - input.val(attr.value).select(); - if (attr.category != "default") { - // 属性名和类型输入 - var nameDiv = item.children(".attr_name"); - nameDiv.empty(); - var nameInput = $("") - .appendTo(nameDiv); - nameInput.val(attr.name).select(); - var typeDiv = item.children(".attr_type"); - typeDiv.empty(); - var select = $("") - .appendTo(typeDiv); - select.html($("#attr_add_type").html()).val(attr.type); - select.bind("change", function() { - Dock.setAttrValueInput(attr, $(this).val()); - }); - } - // 添加显示设置 - var displayArea = $("
        ") - .appendTo(item); - // 显示为的按钮 - displayArea - .append("
        <@i18n resource='diagraming.addattr.displayas'/>
        "); - displayArea - .append("
        "); - displayArea.append("
        "); - // 显示参数区域 - displayArea.append("
        "); - this.appendDisplayItems(); - var showType = "none"; - if (attr.showType) { - showType = attr.showType; - } - this.setAttrDisplay(showType); - $("#attr_edit_showtype").attr("ty", showType).button({ - onMousedown : function() { - $("#attr_display_list").dropdown({ - target : $("#attr_edit_showtype"), - onSelect : function(item) { - var type = item.attr("ty"); - $("#attr_edit_showtype").attr("ty", type).button( - "setText", item.text()); - Dock.setAttrDisplay(type); - } - }); - var type = $("#attr_edit_showtype").text().trim(); - $("#attr_display_list").children().each(function() { - if ($(this).text() == type) { - $("#attr_display_list").dropdown("select", - $(this)); - return false; - } - }); - } - }); - $("#attr_edit_showtype").attr("ty", showType).button( - "setText", - $("#attr_display_list").children("li[ty=" + showType + "]") - .html()); - if (showType != "none") { - $("#attr_display_name").attr("checked", attr.showName); - if (showType == "icon") { - this.setAttrIcon(attr.icon); - } - } - var horizontal = "mostright"; - if (attr.horizontal) { - horizontal = attr.horizontal; - } - var vertical = "mostbottom"; - if (attr.vertical) { - vertical = attr.vertical; - } - $("#attr_location_h").button( - "setText", - $("#attr_location_h_list").children("li[loc=" + horizontal - + "]").html()); - $("#attr_location_h").attr("loc", horizontal); - $("#attr_location_v").button( - "setText", - $("#attr_location_v_list").children("li[loc=" + vertical + "]") - .html()); - $("#attr_location_v").attr("loc", vertical); - // 添加保存按钮 - item - .append("
        <@i18n resource='global.ok'/>
        <@i18n resource='global.cancel'/>
        "); - $("#save_edit_attr").bind("click", function(e) { - e.stopPropagation(); - Dock.saveAttrEdit(attrId); - }); - $("#cancel_edit_attr").bind("click", function(e) { - e.stopPropagation(); - Dock.setAttributeList(); - }) - }, - /** - * 设置数据属性值的输入 - * - * @param {} - * attr - * @param {} - * type - */ - setAttrValueInput : function(attr, type) { - var valueArea; - if (attr != null) { - // 如果为null,则是添加时调用,否则为修改 - valueArea = $(".attr_editing").children(".attr_value"); - } else { - valueArea = $("#attr_add_value_arera"); - } - valueArea.empty(); - var result; - if (type == "boolean") { - result = $("") - .appendTo(valueArea);; - } else if (type == "list") { - result = $("") - .appendTo(valueArea); - if (attr.listItems) { - for (var i = 0; i < attr.listItems.length; i++) { - var listItem = attr.listItems[i]; - result.append(""); - } - } - } else { - result = $("") - .appendTo(valueArea); - } - if (attr == null) { - valueArea.children().css("width", "260px"); - } else { - valueArea.children().css("width", "128px"); - } - return result; - }, - /** - * 添加数据显示的编辑项 - */ - appendDisplayItems : function() { - var optionsArea = $(".attr_display_options"); - // 详细区域,包括是否显示name,图标 - var detailArea = $("
        ") - .appendTo(optionsArea); - detailArea - .append(""); - // 选择图标的Button - var iconButtonArea = $("
        ") - .appendTo(detailArea); - iconButtonArea - .append("
        <@i18n resource='diagraming.addattr.icon'/>
        "); - iconButtonArea - .append("
        "); - iconButtonArea.append("
        "); - if ($("#attr_icon_list").children("li").html() == "") { - // 初始化图标选择 - var html = ""; - var index = 1; - while (index <= 49) { - if (index == 30) { - // 30时,要空出一格 - html += "
        "; - } - html += "
        "; - index++; - } - $("#attr_icon_list").children("li").html(html); - } - // 位置设置区域 - var locationArea = $("
        ") - .appendTo(optionsArea); - locationArea - .append("
        <@i18n resource='diagraming.addattr.display.location'/>
        "); - locationArea - .append("
        <@i18n resource='diagraming.addattr.display.h'/>
        "); - locationArea - .append("
        Most Right
        "); - locationArea.append("
        "); - locationArea - .append("
        <@i18n resource='diagraming.addattr.display.v'/>
        "); - locationArea - .append("
        Most Bottom
        "); - locationArea.append("
        "); - optionsArea.append("
        "); - $("#attr_display_icon").button({ - onMousedown : function() { - $("#attr_icon_list").dropdown({ - target : $("#attr_display_icon") - }); - } - }); - $("#attr_location_h").button({ - onMousedown : function() { - $("#attr_location_h_list").dropdown({ - target : $("#attr_location_h"), - onSelect : function(item) { - $("#attr_location_h").button("setText", - item.html()); - $("#attr_location_h").attr("loc", - item.attr("loc")); - } - }); - } - }); - $("#attr_location_v").button({ - onMousedown : function() { - $("#attr_location_v_list").dropdown({ - target : $("#attr_location_v"), - onSelect : function(item) { - $("#attr_location_v").button("setText", - item.html()); - $("#attr_location_v").attr("loc", - item.attr("loc")); - } - }); - } - }); - }, - /** - * 根据数据属性显示类型,设置操作界面 - * - * @param {} - * type - */ - setAttrDisplay : function(type) { - if (type == "none") { - $(".attr_display_options").hide(); - } else { - $(".attr_display_options").show(); - if (type == "icon") { - $("#attr_icon_area").show(); - } else { - $("#attr_icon_area").hide(); - } - } - }, - /** - * 设置数据属性的显示图标 - * - * @param {} - * icon - */ - setAttrIcon : function(icon) { - $("#attr_display_icon").attr("ico", icon).button("setText", ""); - if (icon) { - $("#attr_display_icon").button("setText", - ""); - } - }, - /** - * 保存数据属性编辑 - * - * @param {} - * attrId - */ - saveAttrEdit : function(attrId) { - var item = $(".attr_item_" + attrId); - if (!item.hasClass("attr_editing")) { - return; - } - var attr = Designer.getDataAttrById(attrId); - if (attr.category != "default") { - var name = item.children(".attr_name").children("input").val(); - if (name == "") { - item.children(".attr_name").children("input").focus(); - return; - } - attr.name = name; - attr.type = item.children(".attr_type").children("select").val(); - } - attr.value = item.children(".attr_value").children().val(); - var showType = $("#attr_edit_showtype").attr("ty"); - attr.showType = showType; - if (showType != "none") { - attr.showName = $("#attr_display_name").is(":checked"); - attr.horizontal = $("#attr_location_h").attr("loc"); - attr.vertical = $("#attr_location_v").attr("loc"); - if (showType == "icon") { - attr.icon = $("#attr_display_icon").attr("ico"); - } - } - // BPMN数据属性规则 - var selectedIds = Utils.getSelectedIds(); - var shape = Model.getShapeById(selectedIds[0]); - if (attr.category == "default" && shape.category == "bpmn") { - if (!shape.attribute) { - shape.attribute = {}; - } - if (!shape.attribute.markers) { - shape.attribute.markers = []; - } - var markers = shape.attribute.markers; - if (attr.name == "loopCharacteristics") { - Utils.removeFromArray(markers, "loop"); - Utils.removeFromArray(markers, "sequential"); - Utils.removeFromArray(markers, "parallel"); - if (attr.value == "StandardLoopCharacteristics") { - // 显示循环 - Utils.addToArray(markers, "loop"); - } else if (attr.value == "MultipleLoopCharacteristics") { - var sequantial = Designer - .getDefaultDataAttrByName("isSequantial"); - if (sequantial != null) { - if (sequantial.value == "true") { - // 显示三条横线 - Utils.addToArray(markers, "sequential"); - } else { - // 显示三条竖线 - Utils.addToArray(markers, "parallel"); - } - } - } - } else if (attr.name == "isSequantial") { - Utils.removeFromArray(markers, "sequential"); - Utils.removeFromArray(markers, "parallel"); - var loop = Designer - .getDefaultDataAttrByName("loopCharacteristics"); - if (loop != null && loop.value == "MultipleLoopCharacteristics") { - if (attr.value == "true") { - // 显示三条横线 - Utils.addToArray(markers, "sequential"); - } else { - // 显示三条竖线 - Utils.addToArray(markers, "parallel"); - } - } - } else if (attr.name == "isForCompensation") { - // 显示两个左箭头 - Utils.removeFromArray(markers, "compensation"); - if (attr.value == "true") { - Utils.addToArray(markers, "compensation"); - } - } else if (attr.name == "isCollection" - || attr.name == "ParticipantMultiplicity") { - Utils.removeFromArray(markers, "parallel"); - if (attr.value == "true") { - // 显示三条竖线 - Utils.addToArray(markers, "parallel"); - } - } else if (attr.name == "loopType") { - Utils.removeFromArray(markers, "loop"); - Utils.removeFromArray(markers, "sequential"); - Utils.removeFromArray(markers, "parallel"); - if (attr.value == "Standard") { - // 显示循环 - Utils.addToArray(markers, "loop"); - } else if (attr.value == "MultiInstanceSequential") { - // 显示三条横线 - Utils.addToArray(markers, "sequential"); - } else if (attr.value == "MultiInstanceParallel") { - // 显示三条竖线 - Utils.addToArray(markers, "parallel"); - } - } - } - Designer.updateDataAttribute(attr); - this.setAttributeList(); - }, - /** - * 删除数据属性 - * - * @param {} - * attrId - */ - deleteAttr : function(attrId, event) { - event.stopPropagation(); - var item = $(".attr_item_" + attrId); - item.remove(); - this.fitAttrList(); - Designer.deleteDataAttribute(attrId); - }, - /** - * 进入全屏 - */ - fullScreen : function(element, presentation) { - if (element.requestFullscreen) { - element.requestFullscreen(); - } else if (element.mozRequestFullScreen) { - element.mozRequestFullScreen(); - } else if (element.webkitRequestFullscreen) { - element.webkitRequestFullscreen(); - } else { - // 无法进入全屏,提示错误 - if (presentation) { - $("#fullscreen_tip").find(".t").text("由于您的浏览器限制,无法进入演示视图。"); - } else { - $("#fullscreen_tip").find(".t").text("无法进入全屏视图,您可以按(F11)进入。"); - } - $("#fullscreen_tip").fadeIn(); - } - }, - /** - * 进入演示视图 - */ - enterPresentation : function() { - $("#designer").bind('webkitfullscreenchange', function(e) { - Dock.manageFullScreen(); - }); - $(document).bind('mozfullscreenchange', function(e) { - Dock.manageFullScreen(); - }).bind('fullscreenchange', function(e) { - Dock.manageFullScreen(); - }); - this.fullScreen(Utils.getDomById("designer"), true); - - }, - /** - * 进入全屏视图 - */ - enterFullScreen : function() { - this.fullScreen(document.documentElement); - }, - manageFullScreen : function() { - var designer = Utils.getDomById("designer"); - if (document.fullscreenElement || document.webkitFullscreenElement - || document.mozFullScreenElement) { - // 如果进入全屏状态 - $("#shape_panel").addClass("readonly"); - $("#designer_viewport").addClass("readonly"); - $(window).unbind("resize.designer"); - $("#designer_layout").height(window.screen.height); - // 取消快捷键 - Designer.hotkey.cancel(); - Designer.op.cancel(); - // 隐藏Dock - $("#dock").hide(); - $(".dock_view").hide(); - Designer.contextMenu.destroy(); - Designer.op.canvasFreeDraggable(); - } else { - $("#shape_panel").removeClass("readonly"); - $("#designer_viewport").removeClass("readonly"); - Designer.initialize.initLayout(); - Designer.hotkey.init(); - Designer.op.init(); - $("#dock").show(); - if (Dock.currentView != "") { - Dock.showView(Dock.currentView); - } - Designer.contextMenu.init(); - $("#designer").unbind('webkitfullscreenchange'); - $("#designer").unbind('mozfullscreenchange') - .unbind('fullscreenchange'); - } - } -}; - -/** - * 鹰眼导航 - * - * @type {} - */ -var Navigator = { - /** - * 初始化 - */ - init : function() { - $("#designer_layout").bind("scroll", function() { - Navigator.setView(); - }); - // 绑定拖动 - $("#navigation_eye").bind("mousedown", function(downE) { - var eye = $(this); - var beginPos = eye.position(); - // 先取消滚动事件 - $("#designer_layout").unbind("scroll"); - var layout = $("#designer_layout"); - var beginTop = layout.scrollTop(); - var beginLeft = layout.scrollLeft(); - // 设计器画布 - var designerCanvas = $("#designer_canvas"); - var canvasW = designerCanvas.width(); - var canvasH = designerCanvas.height(); - // 鹰眼视图画布 - var canvas = $("#navigation_canvas"); - var navW = canvas.width(); - var navH = canvas.height(); - // 宽高比例 - var scaleW = canvasW / navW; - var scaleH = canvasH / navH; - $(document).bind("mousemove.navigator", function(moveE) { - var offsetX = moveE.pageX - downE.pageX; - var offsetY = moveE.pageY - downE.pageY; - var newLeft = beginLeft + offsetX * scaleW; - layout.scrollLeft(newLeft); - var newTop = beginTop + offsetY * scaleH; - layout.scrollTop(newTop); - eye.css({ - left : beginPos.left + offsetX, - top : beginPos.top + offsetY - }); - }); - $(document).bind("mouseup.navigator", function(moveE) { - $(document).unbind("mousemove.navigator"); - $(document).unbind("mouseup.navigator"); - Navigator.setView(); - // 重新绑定 - $("#designer_layout").bind("scroll", - function() { - Navigator.setView(); - }); - }); - }); - $("#navigation_canvas").bind("click", function(e) { - var pos = Utils.getRelativePos(e.pageX, e.pageY, $(this)); - // 设计器画布 - var designerCanvas = $("#designer_canvas"); - var canvasW = designerCanvas.width(); - var canvasH = designerCanvas.height(); - // 鹰眼视图画布 - var canvas = $("#navigation_canvas"); - var navW = canvas.width(); - var navH = canvas.height(); - // 宽高比例 - var scaleW = canvasW / navW; - var scaleH = canvasH / navH; - // 得到点击位置,相对于设计器画布的坐标 - var canvasX = pos.x * scaleW; - var canvasY = pos.y * scaleH; - // 把点击坐标,置于屏幕中心 - var layout = $("#designer_layout"); - var margin = Designer.config.pageMargin; - layout.scrollLeft(canvasX + margin - layout.width() / 2); - layout.scrollTop(canvasY + margin - layout.height() / 2); - }); - this.setView(); - }, - /** - * 绘制鹰眼视图 - */ - draw : function() { - if (this.drawNavigationTimeout) { - window.clearTimeout(this.drawNavigationTimeout); - } - this.drawNavigationTimeout = setTimeout(function() { - var canvas = $("#navigation_canvas"); - var ctx = canvas[0].getContext("2d"); - ctx.save(); - ctx.clearRect(0, 0, canvas.width(), canvas.height()); - ctx.scale(canvas.width() / Model.define.page.width, canvas - .height() - / Model.define.page.height); - // 从最底层开始绘制图形 - for (var i = 0; i < Model.orderList.length; i++) { - var shapeId = Model.orderList[i].id; - var shape = Model.getShapeById(shapeId); - ctx.save(); - if (shape.name != "linker") { - // 对图形执行绘制 - var p = shape.props; - var style = shape.lineStyle; - ctx.translate(p.x, p.y); - ctx.translate(p.w / 2, p.h / 2); - ctx.rotate(p.angle); - ctx.translate(-(p.w / 2), -(p.h / 2)); - ctx.globalAlpha = shape.shapeStyle.alpha; - Designer.painter.renderShapePath(ctx, shape); - } else { - var linker = shape; - var style = linker.lineStyle; - var points = linker.points; - var from = linker.from; - var to = linker.to; - ctx.beginPath(); - ctx.moveTo(from.x, from.y); - if (linker.linkerType == "curve") { - var cp1 = points[0]; - var cp2 = points[1]; - ctx.bezierCurveTo(cp1.x, cp1.y, cp2.x, cp2.y, - to.x, to.y); - } else { - for (var j = 0; j < points.length; j++) { - // 如果是折线,会有折点 - var linkerPoint = points[j]; - ctx.lineTo(linkerPoint.x, linkerPoint.y); - } - ctx.lineTo(to.x, to.y); - } - ctx.lineWidth = style.lineWidth; - ctx.strokeStyle = "rgb(" + style.lineColor + ")"; - ctx.stroke(); - } - ctx.restore(); - } - ctx.restore(); - Navigator.setView(); - this.drawNavigationTimeout = null; - }, 100); - }, - /** - * 设置鹰眼视图 - */ - setView : function() { - var navigator = $("#navigation_eye"); - // 设计器可见视图 - var layout = $("#designer_layout"); - var viewW = layout.width(); - var viewH = layout.height(); - // 鹰眼视图画布 - var canvas = $("#navigation_canvas"); - var navW = canvas.width(); - var navH = canvas.height(); - // 设计器画布 - var designerCanvas = $("#designer_canvas"); - var canvasW = designerCanvas.width(); - var canvasH = designerCanvas.height(); - var margin = Designer.config.pageMargin; - // 得到设计器画布在可视窗口中的left, top - var visibleLeft = margin - layout.scrollLeft(); - var visibleRight = visibleLeft + canvasW; - if (visibleLeft < 0) { - visibleLeft = 0; - } else if (visibleLeft > viewW) { - visibleLeft = viewW; - } - if (visibleRight > viewW) { - visibleRight = viewW; - } else if (visibleRight < 0) { - visibleRight = 0; - } - var visibleTop = margin - layout.scrollTop(); - var visibleBottom = visibleTop + canvasH; - if (visibleTop < 0) { - visibleTop = 0; - } else if (visibleTop > viewH) { - visibleTop = viewH; - } - if (visibleBottom > viewH) { - visibleBottom = viewH; - } else if (visibleBottom < 0) { - visibleBottom = 0; - } - var visibleW = visibleRight - visibleLeft; - var visibleH = visibleBottom - visibleTop; - if (visibleW == 0 || visibleH == 0) { - // 画布已经不可见 - navigator.hide(); - } else { - // 换算成鹰眼视图中的left, top - var navLeft = layout.scrollLeft() - margin; - if (navLeft < 0) { - navLeft = 0; - } - navLeft = navLeft * (navW / canvasW); - var navTop = layout.scrollTop() - margin; - if (navTop < 0) { - navTop = 0; - } - navTop = navTop * (navH / canvasH); - var navViewW = visibleW * (navW / canvasW); - var navViewH = visibleH * (navH / canvasH); - navigator.css({ - left : navLeft - 1, - top : navTop - 1, - width : navViewW, - height : navViewH - }).show(); - } - } -}; -/** - * jQuery的扩展 - */ -(function($) { - /** - * 按钮 - */ - $.fn.button = function(options) { - if (typeof options == "string") { - if (options == "disable") { - $(this).addClass("disabled"); - $(this).find("input").attr("disabled", true); - } else if (options == "enable") { - $(this).removeClass("disabled"); - $(this).find("input").attr("disabled", false); - } else if (options == "isDisabled") { - return $(this).hasClass("disabled"); - } else if (options == "isSelected") { - return $(this).hasClass("selected"); - } else if (options == "unselect") { - $(this).removeClass("selected"); - } else if (options == "select") { - $(this).addClass("selected"); - } else if (options == "setText") { - $(this).children(".text_content").html(arguments[1]); - } else if (options == "setColor") { - $(this).children(".btn_color").css("background-color", - "rgb(" + arguments[1] + ")"); - } else if (options == "getColor") { - var color = $(this).children(".btn_color") - .css("background-color").replace(/\s/g, ""); - return color.substring(4, color.length - 1); - } - return $(this); - } - var target = $(this); - target.unbind("click"); - target.unbind("mousedown") - if (options.onClick) { - target.bind("click", function() { - if (target.button("isDisabled")) { - return; - } - options.onClick(); - }); - } - if (options.onMousedown) { - target.bind("mousedown", function(e) { - if (target.button("isDisabled")) { - return; - } - options.onMousedown(); - e.stopPropagation(); - }); - } - }; - var currentMenu = null; - // 下拉控件 - $.fn.dropdown = function(options) { - var menu = $(this); - menu.find(".ico_selected").remove(); - if (typeof options == "string") { - if (options == "close") { - menu.hide(); - currentMenu.target.removeClass("selected"); - $(document).unbind("mousedown.ui_dropdown"); - currentMenu = null; - } else if (options == "select") { - arguments[1].prepend("
        "); - } - return; - } - if (currentMenu != null) { - /** - * 如果当前有其他菜单是打开的,则要先关闭 - */ - currentMenu.menu.dropdown("close"); - } - var menu = $(this); - var tar = options.target; - currentMenu = { - target : tar, - menu : menu - }; - var offset = tar.offset(); - tar.addClass("selected"); - menu.show(); - var left; - if (options.position == "center") { - left = offset.left + tar.outerWidth() / 2 - menu.outerWidth() / 2; - } else if (options.position == "right") { - left = offset.left + tar.outerWidth() - menu.outerWidth(); - } else { - left = offset.left; - } - var top = offset.top + tar.outerHeight(); - if (top + menu.outerHeight() > $(window).height()) { - top = $(window).height() - menu.outerHeight(); - } - menu.css({ - top : top, - left : left - }); - if (typeof options.zindex != "undefined") { - menu.css("z-index", options.zindex); - } - menu.unbind("mousedown").bind("mousedown", function(e) { - e.stopPropagation(); - }); - if (typeof options.bind == "undefined" || options.bind == true) { - menu.find("li:not(.devider,.menu_text)").unbind().bind("click", - function() { - var item = $(this); - if (!item.menuitem("isDisabled") - && item.children(".extend_menu").length == 0) { - if (options.onSelect) { - options.onSelect(item); - } - menu.dropdown("close"); - } - }); - } - $(document).bind("mousedown.ui_dropdown", function() { - menu.dropdown("close"); - }); - }; - // 调色板 - $.colorpicker = function(options) { - var picker = $("#color_picker"); - picker.find(".selected").removeClass("selected"); - if (!picker.attr("init")) { - // 没有经过初始化 - picker.find("div").each(function() { - var color = $(this).css("background-color"); - color = color.replace(/\s/g, ""); - color = color.substring(4, color.length - 1); - $(this).attr("col", color); - }); - picker.attr("init", true); - } - var opt = $.extend({}, options, { - bind : false - }); - picker.dropdown(opt); - picker.children(".color_items").children("div").unbind().bind("click", - function() { - if (options.onSelect) { - var color = $(this).css("background-color"); - color = color.replace(/\s/g, ""); - color = color.substring(4, color.length - 1); - options.onSelect(color); - } - $("#color_picker").dropdown("close"); - }); - if (options.color) { - picker.find("div[col='" + options.color + "']") - .addClass("selected"); - } - $("#color_picker").children(".color_extend").remove(); - if (options.extend) { - $("#color_picker").append("
        " - + options.extend + "
        ") - } - }; - // 颜色按钮 - $.fn.colorButton = function(opt) { - var tar = $(this); - if (typeof opt == "string") { - if (opt == "setColor") { - tar.children(".picker_btn_holder").css("background-color", - "rgb(" + arguments[1] + ")"); - } - return; - } - tar - .html("
        "); - tar.bind("mousedown", function(e) { - if (tar.button("isDisabled")) { - return; - } - e.stopPropagation(); - var options = $.extend({}, opt); - options.target = tar; - options.onSelect = function(color) { - tar.colorButton("setColor", color); - if (opt.onSelect) { - opt.onSelect(color); - } - }; - var color = $(this).children(".picker_btn_holder") - .css("background-color"); - color = color.replace(/\s/g, ""); - color = color.substring(4, color.length - 1); - options.color = color; - $.colorpicker(options); - }); - }; - /** - * 数字框 min: 0, max: 360, unit: "°", step: 15, - */ - $.fn.spinner = function(opt) { - var spinner = $(this); - if (typeof opt == "string") { - if (opt == "getValue") { - var result = spinner.find("input").val(); - result = parseFloat(result); - return result; - } else if (opt == "setValue") { - spinner.find("input").val(arguments[1]); - spinner.attr("old", arguments[1]); - } - return; - } - spinner.html("
        "); - var defaults = { - min : 0, - max : Number.MAX_VALUE, - step : 1, - unit : "" - }; - opt = $.extend(defaults, opt); - var inputBox = spinner.children(".spinner_input"); - var input = inputBox.find("input"); - spinner.spinner("setValue", opt.min + opt.unit); - spinner.find(".spinner_up").bind("click", function() { - if (spinner.button("isDisabled")) { - return; - } - var now = spinner.spinner("getValue"); - var newVal = now + opt.step; - setSpinnerValue(spinner, newVal, opt); - }); - spinner.find(".spinner_down").bind("click", function() { - if (spinner.button("isDisabled")) { - return; - } - var now = spinner.spinner("getValue"); - var newVal = now - opt.step; - setSpinnerValue(spinner, newVal, opt); - }); - input.bind("keydown", function(e) { - if (e.keyCode == 13) { - var newVal = parseInt($(this).val()); - if (isNaN(newVal)) { - newVal = opt.min; - } - setSpinnerValue(spinner, newVal, opt); - } - }).bind("focus", function(e) { - $(this).select(); - $(this).bind("mouseup", function(e) { - e.preventDefault(); - $(this).unbind("mouseup"); - }); - var box = $(this).parent().parent(); - if (!box.hasClass("active")) { - box.addClass("active inset"); - } - }).bind("blur", function(e) { - var box = $(this).parent().parent(); - if (box.hasClass("inset")) { - box.removeClass("active inset"); - } - }); - }; - function setSpinnerValue(spinner, value, opt) { - if (value > opt.max) { - value = opt.max; - } - if (value < opt.min) { - value = opt.min; - } - var oldValue = spinner.attr("old"); - var newValue = value + opt.unit; - if (oldValue != newValue) { - if (opt.onChange) { - opt.onChange(value); - } - } - spinner.spinner("setValue", value + opt.unit); - } - /** - * 菜单项 - */ - $.fn.menuitem = function(options) { - var target = $(this); - if (typeof options == "string") { - if (options == "disable") { - target.addClass("disabled"); - } else if (options == "enable") { - target.removeClass("disabled"); - } else if (options == "isDisabled") { - return target.hasClass("disabled"); - } else if (options == "isSelected") { - return target.children(".ico_selected").length > 0; - } else if (options == "unselect") { - return target.children(".ico_selected").remove(); - } else if (options == "select") { - return target.prepend("
        ") - } - } - }; - /** - * 窗口 - */ - $.fn.dlg = function(options) { - var dlg = $(this); - if (typeof options == "string") { - if (options == "close") { - dlg.children(".dlg_close").trigger("click"); - } - return; - } - var defaults = { - closable : true - }; - options = $.extend(defaults, options); - var close = dlg.children(".dlg_close"); - if (close.length == 0) { - close = $("
        ").appendTo(dlg); - } - if (options.closable == false) { - close.hide(); - } else { - close.show(); - } - $(".dlg_mask").remove(); - $("body").append("
        ") - close.unbind().bind("click", function() { - dlg.hide(); - $(".dlg_mask").remove(); - if (options && options.onClose) { - options.onClose(); - } - $(document).unbind("keydown.closedlg"); - dlg.find("input,textarea,select") - .unbind("keydown.closedlg"); - }); - dlg.css({ - left : ($(window).width() - dlg.outerWidth()) / 2, - top : ($(window).height() - dlg.outerHeight()) / 2 - }); - dlg.show(); - if (options.closable) { - dlg.find("input,textarea,select").unbind("keydown.closedlg").bind( - "keydown.closedlg", function(e) { - if (e.keyCode == 27) { - dlg.children(".dlg_close").trigger("click"); - } - }); - $(document).unbind("keydown.closedlg").bind("keydown.closedlg", - function(e) { - if (e.keyCode == 27) { - dlg.children(".dlg_close").trigger("click"); - } - }); - } - dlg.children(".dialog_header").unbind("mousedown.drag_dlg").bind( - "mousedown.drag_dlg", function(e) { - var target = $(this).parent(); - var downX = e.pageX; - var downY = e.pageY; - var downLeft = target.offset().left; - var downTop = target.offset().top; - $(document).bind("mousemove.drag_dlg", function(e) { - var left = e.pageX - downX + downLeft; - var top = e.pageY - downY + downTop; - target.offset({ - left : left, - top : top - }); - }); - $(document).bind("mouseup.drag_dlg", function(e) { - $(document).unbind("mousemove.drag_dlg"); - $(document).unbind("mouseup.drag_dlg"); - }); - }); - }; -})(jQuery); +var UI={init:function(){$(".diagram_title").bind("click",function(){if($(this).hasClass("readonly")){return}var title=$(this).text();$(this).hide();$("#title_container").append("");$("#title_container").children("input").val(title.replace(/(^\s+)|(\s+$)/g,"")).select();$("#title_container").children("input").bind("blur",function(){changeTitle()}).bind("keydown",function(e){if(e.keyCode==13){changeTitle()}})});function changeTitle(){var newTitle=$.trim($("#title_container").children("input").val());newTitle=newTitle.replace(/(^\s+)|(\s+$)/g,"");var oldTitle=$(".diagram_title").text();oldTitle=oldTitle.replace(/(^\s+)|(\s+$)/g,"");if(newTitle!=oldTitle&&chartId!=""){var msgObj={action:"changeTitle",title:newTitle};CLB.send(msgObj)}var title=newTitle!=""?newTitle:oldTitle;$("title").text(title);$(".diagram_title").text(title).show();$("#title_container").children("input").remove();awsui.ajax.request({url:'./jd?cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_updatetitle&sid='+encodeURIComponent(sid)+'&uuid='+ruuid+'&title='+encodeURIComponent(title)+'&processDefId='+process.processDefId+'&appId='+appId,async:false,ok:function(msg){$("#file_attribute").contents().find("input[id='plName']").val(title);try{window.opener.parent.window.top.document.main_iframe.teamAppFrame.contentWindow._d157b007c785d2d988d3d81c8ddcb1b8.contentWindow.refresh()}catch(e){try{window.opener.parent.window.top.document.main_iframe.teamAppFrame.contentWindow._d157b007c785d2d988d3d81c8ddcb1b8.contentWindow.refresh()}catch(e){}}if(parent.repositoryTree){parent.repositoryTree.refreshNodeById({id:ruuid,name:title})}if(parent.awsTabs){parent.awsTabs.setTitle(ruuid,title)}if(Model.define.coeProperties){Model.define.coeProperties.fileName=title}}})}$("#bar_undo").button({onClick:function(){MessageSource.undo()}});$("#bar_redo").button({onClick:function(){MessageSource.redo()}});$("#bar_brush").button({onClick:function(){if($("#bar_brush").button("isSelected")){$("#bar_brush").button("unselect");$("#designer_op_help").hide();$(document).unbind("keydown.cancelbrush");Utils.selectCallback=null}else{Designer.clipboard.brush()}}});$("#bar_font_family").button({onMousedown:function(){$("#font_list").dropdown({target:$("#bar_font_family"),onSelect:function(item){var font=item.text();Designer.setFontStyle({fontFamily:font});$("#bar_font_family").button("setText",font)}});var family=$("#bar_font_family").text().trim();$("#font_list").children().each(function(){if($(this).text()==family){$("#font_list").dropdown("select",$(this));return false}})}});$("#bar_font_size").spinner({min:12,max:100,step:1,unit:"px",onChange:function(val){Designer.setFontStyle({size:val})}});$("#bar_font_size").spinner("setValue","13px");$("#bar_font_bold").button({onClick:function(){var bold=!$("#bar_font_bold").button("isSelected");Designer.setFontStyle({bold:bold});$("#bar_font_bold").toggleClass("selected")}});$("#bar_font_italic").button({onClick:function(){var italic=!$("#bar_font_italic").button("isSelected");Designer.setFontStyle({italic:italic});$("#bar_font_italic").toggleClass("selected")}});$("#bar_font_underline").button({onClick:function(){var underline=!$("#bar_font_underline").button("isSelected");Designer.setFontStyle({underline:underline});$("#bar_font_underline").toggleClass("selected")}});$("#bar_font_color").button({onMousedown:function(){var color=$("#bar_font_color").button("getColor");$.colorpicker({target:$("#bar_font_color"),onSelect:function(color){Designer.setFontStyle({color:color});$("#bar_font_color").button("setColor",color)},color:color})}});$("#bar_font_align").button({onMousedown:function(){$("#font_align_list").dropdown({target:$("#bar_font_align"),onSelect:function(item){var align={};align[item.attr("cate")]=item.attr("al");Designer.setFontStyle(align)}})}});$("#bar_fill").button({onMousedown:function(){var color=$("#bar_fill").button("getColor");$.colorpicker({target:$("#bar_fill"),onSelect:function(color){Designer.setFillStyle({type:"solid",color:color});$("#bar_fill").button("setColor",color)},color:color,extend:"
        "});$("#bar_fill_gradient").unbind().bind("click",function(){Designer.setFillStyle({type:"gradient"});$("#color_picker").dropdown("close")});$("#bar_fill_img").unbind().bind("click",function(){UI.showImageSelect(function(fileId,w,h){Designer.setFillStyle({type:"image",fileId:fileId,imageW:w,imageH:h})});$("#color_picker").dropdown("close")});$("#bar_fill_more").unbind().bind("click",function(){Dock.showView("graphic");$("#color_picker").dropdown("close")})}});$("#bar_line_color").button({onMousedown:function(){var color=$("#bar_line_color").button("getColor");$.colorpicker({target:$("#bar_line_color"),onSelect:function(color){Designer.setLineStyle({lineColor:color});$("#bar_line_color").button("setColor",color)},color:color})}});$("#bar_line_width").button({onMousedown:function(){$("#line_width_list").dropdown({target:$("#bar_line_width"),onSelect:function(item){var width=parseInt(item.text());Designer.setLineStyle({lineWidth:width})}});var width=Utils.getSelected()[0].lineStyle.lineWidth;$("#line_width_list").children().each(function(){if(parseInt($(this).text())==width){$("#line_width_list").dropdown("select",$(this))}})}});$("#bar_line_style").button({onMousedown:function(){$("#line_style_list").dropdown({target:$("#bar_line_style"),onSelect:function(item){var lineStyle=item.attr("line");Designer.setLineStyle({lineStyle:lineStyle})}});var style=Utils.getSelected()[0].lineStyle.lineStyle;var item=$("#line_style_list").children("li[line="+style+"]");$("#line_style_list").dropdown("select",item)}});$("#bar_linkertype").button({onMousedown:function(){$("#line_type_list").dropdown({target:$("#bar_linkertype"),onSelect:function(item){var type=item.attr("tp");Designer.setLinkerType(type);var cls=item.children("div").attr("class");$("#bar_linkertype").children("div:eq(0)").attr("class",cls)}})}});$("#bar_beginarrow").button({onMousedown:function(){$("#beginarrow_list").dropdown({target:$("#bar_beginarrow"),onSelect:function(item){var arrow=item.attr("arrow");Designer.setLineStyle({beginArrowStyle:arrow});var cls=item.children("div").attr("class");$("#bar_beginarrow").children("div:eq(0)").attr("class",cls)}});var style=Utils.getSelectedLinkers()[0].lineStyle.beginArrowStyle;var item=$("#beginarrow_list").children("li[arrow="+style+"]");$("#beginarrow_list").dropdown("select",item)}});$("#bar_endarrow").button({onMousedown:function(){$("#endarrow_list").dropdown({target:$("#bar_endarrow"),onSelect:function(item){var arrow=item.attr("arrow");Designer.setLineStyle({endArrowStyle:arrow});var cls=item.children("div").attr("class");$("#bar_endarrow").children("div:eq(0)").attr("class",cls)}});var style=Utils.getSelectedLinkers()[0].lineStyle.endArrowStyle;var item=$("#endarrow_list").children("li[arrow="+style+"]");$("#endarrow_list").dropdown("select",item)}});$("#bar_front").button({onClick:function(){Designer.layerShapes("front")}});$("#bar_back").button({onClick:function(){Designer.layerShapes("back")}});$("#bar_lock").button({onClick:function(){Designer.lockShapes()}});$("#bar_unlock").button({onClick:function(){Designer.unlockShapes()}});$("#bar_link").button({onClick:function(){UI.showInsertLink()}});$("#bar_risk").button({onClick:function(){UI.showRiskDlg()}});$("#bar_importShape").button({onClick:function(){UI.showImportShapeDlg()}});$("#bar_import").button({onClick:function(){UI.showImportDlg()}});$("#bar_importPolicyFile").button({onClick:function(){UI.showImportPolicyFileDlg()}});$("#bar_upfile").button({onClick:function(){openUpFile()}});$("#bar_activityNo").button({onClick:function(){UI.activityNoDlg()}});$("#bar_arrange").button({onMousedown:function(){$("#bar_list_arrange").dropdown({target:$("#bar_arrange"),onSelect:function(item){menuSelected(item)}})}});$("#bar_view").button({onMousedown:function(){$("#bar_list_view").dropdown({target:$("#bar_view"),onSelect:function(item){menuSelected(item)}})}});$("#menu_bar").children().bind("mousedown",function(e){var tar=$(this);showMenuBarList(tar);e.stopPropagation()});$("#menu_bar").children().bind("mouseenter",function(){var tar=$(this);if($("#ui_container").find(".options_menu:visible").length>0){showMenuBarList(tar)}});function showMenuBarList(menuBar){var menuId=menuBar.attr("menu");if(menuBar.hasClass("readonly")){return}$("#"+menuId).dropdown({target:menuBar,onSelect:function(item){menuSelected(item)}});if(menuId=="bar_list_page"){if(Model.define.page.showGrid){$("#bar_list_page").dropdown("select",$("#bar_list_page").children("li[ac=set_page_showgrid]"))}else{$("#bar_list_page").dropdown("unselect",$("#bar_list_page").children("li[ac=set_page_showgrid]"))}var item=$("#bar_list_pagesize li[w="+Model.define.page.width+"][h="+Model.define.page.height+"]");if(item.length>0){$("#bar_list_pagesize").dropdown("select",item)}else{$("#bar_list_pagesize").dropdown("select",$("#page_size_custom"))}$("#page_size_w").spinner("setValue",Model.define.page.width+"px");$("#page_size_h").spinner("setValue",Model.define.page.height+"px");item=$("#bar_list_padding").children("li[p="+Model.define.page.padding+"]");$("#bar_list_padding").dropdown("select",item);item=$("#bar_list_gridsize").children("li[s="+Model.define.page.gridSize+"]");$("#bar_list_gridsize").dropdown("select",item)}else if(menuId=="bar_list_view"){var item=$("#bar_list_view").children(".static[zoom='"+Designer.config.scale+"']");if(item.length){$("#bar_list_page").dropdown("select",item)}}}function menuSelected(item){var action=item.attr("ac");if(action=="rename"){$(".diagram_title").trigger("click")}else if(action=="close"){if(parent.closeTabById){parent.closeTabById(chartId)}else{window.close()}}else if(action=="saveAs"){UI.showSaveAs()}else if(action=="preview"){UI.doPreview()}else if(action=="saveImage"){UI.saveImage()}else if(action=="versionCompare"){UI.showVersionCompare()}else if(action=="output"){UI.doOutputProcess()}else if(action=="export"){$("#export_dialog").dlg()}else if(action=="processExport"){UI.processExport()}else if(action=="undo"){MessageSource.undo()}else if(action=="redo"){MessageSource.redo()}else if(action=="cut"){Designer.clipboard.cut()}else if(action=="copy"){Designer.clipboard.copy()}else if(action=="paste"){Designer.clipboard.paste()}else if(action=="duplicate"){Designer.clipboard.duplicate()}else if(action=="brush"){Designer.clipboard.brush()}else if(action=="selectall"){Designer.selectAll()}else if(action=="openNewPage"){UI.openNewPage()}else if(action=="batchreplace"){UI.batchReplace()}else if(action=="delete"){Designer.op.removeShape()}else if(action=="zoom"){var zoom=item.attr("zoom");if(zoom=="in"){Designer.zoomIn()}else if(zoom=="out"){Designer.zoomOut()}else{var zoomScale=parseFloat(zoom);Designer.setZoomScale(zoomScale)}}else if(action=="insert"){var insertType=item.attr("in");if(insertType=="text"){Designer.op.changeState("creating_free_text")}else if(insertType=="image"){UI.showImageSelect(function(fileId,w,h){UI.insertImage(fileId,w,h)})}else if(insertType=="line"){Designer.op.changeState("creating_free_linker")}}else if(action=="set_page_size"){var w=parseInt(item.attr("w"));var h=parseInt(item.attr("h"));Designer.setPageStyle({width:w,height:h})}else if(action=="set_page_padding"){var p=parseInt(item.attr("p"));Designer.setPageStyle({padding:p})}else if(action=="set_page_showgrid"){if(item.menuitem("isSelected")){item.menuitem("unselect");Designer.setPageStyle({showGrid:false})}else{item.menuitem("select");Designer.setPageStyle({showGrid:true})}}else if(action=="set_page_gridsize"){var s=parseInt(item.attr("s"));Designer.setPageStyle({gridSize:s})}else if(action=="front"){Designer.layerShapes("front")}else if(action=="back"){Designer.layerShapes("back")}else if(action=="forward"){Designer.layerShapes("forward")}else if(action=="backward"){Designer.layerShapes("backward")}else if(action=="align_shape"){var align=item.attr("al");Designer.alignShapes(align)}else if(action=="distribute_shape"){var type=item.attr("dis");Designer.distributeShapes(type)}else if(action=="match_size"){if(item.attr("custom")){Dock.showView("metric")}else{var type={};var w=item.attr("w");var h=item.attr("h");if(w){type.w=w}if(h){type.h=h}Designer.matchSize(type)}}else if(action=="lock"){Designer.lockShapes()}else if(action=="unlock"){Designer.unlockShapes()}else if(action=="group"){Designer.group()}else if(action=="ungroup"){Designer.ungroup()}else if(action=="hotkey"){UI.showHotKey()}else if(action=="feedback"){UI.showFeedBack()}else if(action=="getting_started"){UI.gettingStart()}}$("#page_size_w").spinner({min:200,unit:"px",step:100,onChange:function(val){Designer.setPageStyle({width:val})}});$("#page_size_h").spinner({min:200,unit:"px",step:100,onChange:function(val){Designer.setPageStyle({height:val})}});var pickerHtml=$("#color_picker").html();var newPicker=$("").appendTo($("#bar_page_color"));newPicker.css("right","-179px");newPicker.children(".color_items").children("div").unbind().bind("click",function(){var color=$(this).css("background-color");color=color.replace(/\s/g,"");color=color.substring(4,color.length-1);Designer.setPageStyle({backgroundColor:color});$("#bar_list_page").dropdown("close")});Designer.events.push("selectChanged",0);Designer.events.push("clipboardChanged",0);Designer.events.push("undoStackChanged",0);Designer.events.push("redoStackChanged",0)},update:function(){var selectedIds=Utils.getSelectedIds();var count=selectedIds.length;var linkerIds=Utils.getSelectedLinkerIds();var linkerCount=linkerIds.length;var shapeIds=Utils.getSelectedShapeIds();var shapeCount=shapeIds.length;var lockedCount=Utils.getSelectedLockedIds().length;var groupCount=Utils.getSelectedGroups().length;var arrangeMenu=$("#bar_list_arrange");if(count==0){$(".toolbar").find(".selected").removeClass("selected");if($("#designer_op_help").is(":visible")){$("#bar_brush").button("enable");$("#bar_brush").button("select")}else{$("#bar_brush").button("disable")}$("#bar_font_family").button("disable");$("#bar_font_size").button("disable");$("#bar_font_bold").button("disable");$("#bar_font_italic").button("disable");$("#bar_font_underline").button("disable");$("#bar_font_color").button("disable");$("#bar_font_align").button("disable");$("#bar_line_color").button("disable");$("#bar_line_width").button("disable");$("#bar_line_style").button("disable");$("#bar_front").button("disable");$("#bar_back").button("disable");$("#bar_lock").button("disable");var editMenu=$("#bar_list_edit");editMenu.children("li[ac=cut]").menuitem("disable");editMenu.children("li[ac=copy]").menuitem("disable");editMenu.children("li[ac=duplicate]").menuitem("disable");editMenu.children("li[ac=brush]").menuitem("disable");editMenu.children("li[ac=delete]").menuitem("disable");arrangeMenu.children("li[ac=front]").menuitem("disable");arrangeMenu.children("li[ac=back]").menuitem("disable");arrangeMenu.children("li[ac=forward]").menuitem("disable");arrangeMenu.children("li[ac=backward]").menuitem("disable");arrangeMenu.children("li[ac=lock]").menuitem("disable");$("#bar_activityNo").button("enable");$("#bar_activityNo div").removeClass('extend_activityNoDisable');$("#bar_activityNo div").addClass('extend_activityNo')}else{if(editable){$("#bar_brush").button("enable");if($("#designer_op_help").is(":visible")){$("#bar_brush").button("select")}$("#bar_font_family").button("enable");$("#bar_font_size").button("enable");$("#bar_font_bold").button("enable");$("#bar_font_italic").button("enable");$("#bar_font_underline").button("enable");$("#bar_font_color").button("enable");$("#bar_font_align").button("enable");$("#bar_line_color").button("enable");$("#bar_line_width").button("enable");$("#bar_line_style").button("enable");$("#bar_front").button("enable");$("#bar_back").button("enable");$("#bar_lock").button("enable");var editMenu=$("#bar_list_edit");editMenu.children("li[ac=cut]").menuitem("enable");editMenu.children("li[ac=copy]").menuitem("enable");editMenu.children("li[ac=duplicate]").menuitem("enable");editMenu.children("li[ac=brush]").menuitem("enable");editMenu.children("li[ac=delete]").menuitem("enable");arrangeMenu.children("li[ac=front]").menuitem("enable");arrangeMenu.children("li[ac=back]").menuitem("enable");arrangeMenu.children("li[ac=forward]").menuitem("enable");arrangeMenu.children("li[ac=backward]").menuitem("enable");arrangeMenu.children("li[ac=lock]").menuitem("enable");var shape=Model.getShapeById(selectedIds[0]);$("#bar_font_family").button("setText",shape.fontStyle.fontFamily);$("#bar_font_size").spinner("setValue",shape.fontStyle.size+"px");if(shape.fontStyle.bold){$("#bar_font_bold").button("select")}else{$("#bar_font_bold").button("unselect")}if(shape.fontStyle.italic){$("#bar_font_italic").button("select")}else{$("#bar_font_italic").button("unselect")}if(shape.fontStyle.underline){$("#bar_font_underline").button("select")}else{$("#bar_font_underline").button("unselect")}$("#bar_font_color").button("setColor",shape.fontStyle.color);$("#bar_line_color").button("setColor",shape.lineStyle.lineColor);$("#bar_activityNo").button("disable");$("#bar_activityNo div").removeClass('extend_activityNo');$("#bar_activityNo div").addClass('extend_activityNoDisable')}}if(count==0){$("#toolbar-data-attr").button("disable");$("#toolbar-data-attr").unbind("click");$("#bar_arrange").button("disable")}else{$("#toolbar-data-attr").button("enable");$("#toolbar-data-attr").bind("click",function(){showPropertiesDialog()});$("#bar_arrange").button("enable")}if(shapeCount==0){$("#bar_fill").button("disable");$("#toolbar-shape-attr").button("disable")}else{if(editable){$("#bar_fill").button("enable")}var shape=Model.getShapeById(shapeIds[0]);if(shape.fillStyle.type=="solid"){$("#bar_fill").button("setColor",shape.fillStyle.color)}else if(shape.fillStyle.type=="gradient"){$("#bar_fill").button("setColor",shape.fillStyle.endColor)}if(shapeCount==1&&shape.name==BPMN_TYPE_USER_TASK){$("#toolbar-shape-attr").button("enable")}else{$("#toolbar-shape-attr").button("disable")}}if(shapeCount!=1){$("#bar_link, #bar_risk").button("disable");$("#dock_btn_shapeConfig").button("disable");$("#dock_btn_shapeConfig").bind('click',function(){$.simpleAlert("请选择形状")})}else{$("#dock_btn_shapeConfig").unbind('click');$("#dock_btn_shapeConfig").button("enable");if(editable){$("#bar_link").button("enable")}if($('#bar_rmark').length==0&&$('#bar_cancel_aws_correlate').length==0){$("#bar_risk").button("enable")}else{$("#bar_risk").button("disable")}}if(linkerCount==0){$("#bar_linkertype").button("disable");$("#bar_beginarrow").button("disable");$("#bar_endarrow").button("disable")}else{$("#bar_linkertype").button("enable");$("#bar_beginarrow").button("enable");$("#bar_endarrow").button("enable");var shape=Model.getShapeById(linkerIds[0]);$("#bar_linkertype").children("div:eq(0)").attr("class","ico linkertype_"+shape.linkerType.toLowerCase());if(typeof shape.lineStyle.beginArrowStyle!="undefined"){$("#bar_beginarrow").children("div:eq(0)").attr("class","ico ico_arrow larrow_"+shape.lineStyle.beginArrowStyle.toLowerCase())}if(typeof shape.lineStyle.endArrowStyle!="undefined"){$("#bar_endarrow").children("div:eq(0)").attr("class","ico ico_arrow rarrow_"+shape.lineStyle.endArrowStyle.toLowerCase())}}if(lockedCount==0){$("#bar_unlock").button("disable");arrangeMenu.children("li[ac=unlock]").menuitem("disable")}else{$("#bar_unlock").button("enable");arrangeMenu.children("li[ac=unlock]").menuitem("enable")}if(count<2){arrangeMenu.children("li[ac=group]").menuitem("disable");$("#bar_arrange_align").menuitem("disable")}else{arrangeMenu.children("li[ac=group]").menuitem("enable");$("#bar_arrange_align").menuitem("enable")}if(shapeCount<2){$("#bar_arrange_match").menuitem("disable")}else{$("#bar_arrange_match").menuitem("enable")}if(count<3){$("#bar_arrange_dist").menuitem("disable")}else{$("#bar_arrange_dist").menuitem("enable")}if(groupCount==0){arrangeMenu.children("li[ac=ungroup]").menuitem("disable")}else{arrangeMenu.children("li[ac=ungroup]").menuitem("enable")}if($("#dock_btn_eteanalysis").length!=0){if(count==0){$("#dock_btn_eteanalysis").find(".awsui-iconfont").css("color","black");$("#dock_btn_eteanalysis").button("enable");$("#dock_btn_eteanalysis").removeAttr("onclick");$("#dock_btn_eteanalysis").off("click").on("click",function(){var f=$('#eteCascadeAnalysisForm');f.find(':input[name=uuid]').val(ruuid);f.submit()})}else{$("#dock_btn_eteanalysis").find(".awsui-iconfont").css("color","gray");$("#dock_btn_eteanalysis").button("disable");$("#dock_btn_eteanalysis").removeAttr("onclick");$("#dock_btn_eteanalysis").off("click")}}},showInsertLink:function(){$("#link_dialog").dlg();var addr=Utils.getSelected()[0].link;if(!addr){addr=""}$("#linkto_addr").val(addr).select();$("#linkto_addr").unbind().bind("keydown",function(e){if(e.keyCode==13){UI.setLink()}})},setLink:function(){var newLink=$("#linkto_addr").val();var shape=Utils.getSelected()[0];shape.link=newLink;Model.update(shape);$('#link_dialog').dlg('close')},imageSelectedCallback:null,showImageSelect:function(callback){if(callback){this.imageSelectedCallback=callback}else{this.imageSelectedCallback=null}this.fetchingRequest=null;var height=$(window).height()-200;if(height>550){height=550}else if(height<200){height=200}$(".image_list").height(height);$("#image_dialog").dlg({onClose:function(){if(UI.fetchingRequest){UI.fetchingRequest.abort()}}});if($("#image_select_upload").is(":visible")){UI.loadUserImages()};$(".image_sources").children().unbind().bind("click",function(){UI.showImageSelectContent($(this).attr("ty"))});$("#upload_img_res").empty();$("#input_upload_image").unbind().bind("change",function(){$("#upload_img_res").html("上传中...");$("#frm_upload_image").submitForm({success:function(result){if(result.result=="type_wrong"){$("#upload_img_res").html("此文件不是图片,请重新选择")}else if(result.result=="size_wrong"){$("#upload_img_res").html("文件大小超出要求,最大2M")}else if(result.result=="exception"){$("#upload_img_res").html("无法使用此图片,请选择其他图片")}else{var img=result.image;UI.setShapeImage(img.fileId,img.imageW,img.imageH)}}})});$("#input_img_url").val("");$("#img_url_area").empty();var oldUrl="";function urlChanged(){var url=$("#input_img_url").val().trim();if(url!=oldUrl){oldUrl=url if(url!=""){if(url.indexOf("http")<0){url="http://"+url}$("#img_url_area").html("正在加载预览...");var newImage=$("").appendTo("#img_url_area");newImage.unbind().bind("load",function(){newImage.show().addClass("img_url_loaded");$(".img_url_loading_tip").remove()}).bind("error",function(){$("#img_url_area").html("
        无法在此地址下加载图片。
        • 请检查图片地址是否输入正确。
        • 确保图片地址是公开的。
          ")})}}}$("#input_img_url").unbind().bind("paste",function(){urlChanged()}).bind("keyup",function(){urlChanged()});$("#input_img_search").unbind().bind("keydown",function(e){if(e.keyCode==13){UI.searchImgByGoogle()}});$("#btn_img_search").unbind().bind("click",function(){UI.searchImgByGoogle()});$("#set_image_submit").button("enable");$("#set_image_submit").button({onClick:function(){var currentTab=$(".image_sources").children(".active").attr("ty");if(currentTab=="upload"){var selectedImg=$("#user_image_items").children(".image_item_selected");if(selectedImg.length>0){var fileId=selectedImg.attr("fileId");var imageW=selectedImg.attr("w");var imageH=selectedImg.attr("h");UI.setShapeImage(fileId,imageW,imageH)}else{$("#image_dialog").dlg("close")}}else if(currentTab=="url"){if($(".img_url_loaded").length>0){var url=$(".img_url_loaded").attr("src");UI.setShapeImageByURL(url)}else{$("#image_dialog").dlg("close")}}else{var selectedImg=$("#google_image_items").children(".image_item_selected");if(selectedImg.length>0){var url=selectedImg.attr("u");UI.setShapeImageByURL(url)}else{$("#image_dialog").dlg("close")}}}});$("#set_image_cancel").button({onClick:function(){$("#image_dialog").dlg("close")}});$("#set_image_text").empty()},showImageSelectContent:function(type){$(".image_list").hide();$("#image_select_"+type).show().find("input[type=text]").select();$(".image_sources").children().removeClass("active");$(".image_sources").children("li[ty="+type+"]").addClass("active")},loadUserImages:function(refresh){$("#user_image_items").empty();$.ajax({url:"/user_image/list",success:function(data){if(data.images){for(var i=0;i")}}});$("#user_image_items").attr("loaded","true")},searchIndex:0,searchKeywords:"",searchImgByGoogle:function(){var keywords=$("#input_img_search").val();if(keywords.trim()!=""){$("#google_image_items").empty();this.searchKeywords=encodeURI(keywords);this.searchIndex=0;this.loadGoogleImg()}else{$("#input_img_search").focus()}},loadGoogleImg:function(){$.getScript("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q="+this.searchKeywords+"&rsz=8&start="+(this.searchIndex*16)+"&callback=UI.googleImgCallback");$.getScript("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q="+this.searchKeywords+"&rsz=8&start="+(this.searchIndex*16+8)+"&callback=UI.googleImgCallback");$(".gg_img_more").remove();$("#google_image_items").append("
          正在加载图片...
          ");this.searchIndex++},googleImgCallback:function(data){var responseData=data.responseData;var results=responseData.results;for(var i=0;i");$(".img_gg_loading_tip").remove();$(".gg_img_more").remove();if(this.searchIndex<=3){$("#google_image_items").append("
          显示更多结果...
          ")}},appendUserImage:function(img){var box=$("
          ").appendTo($("#user_image_items"));box.unbind().bind("click",function(){$(".image_item_selected").removeClass('image_item_selected');$(this).addClass('image_item_selected')}).bind("mouseenter",function(){var target=$(this);var remove=$("
          ").appendTo(target);var id=target.attr("id");remove.bind("click",function(){target.fadeOut();$.ajax({url:"/user_image/remove",data:{imageId:id}})})}).bind("mouseleave",function(){$(this).find(".ico_remove_red").remove()});var location=img.fileId;var newImage=$("").appendTo(box);newImage.bind("load",function(){$(this).css("margin-top",(140-$(this).height())/2)})},appendGoogleImage:function(img){var title=img.title+" ("+img.width+" × "+img.height+")";var box=$("
          ").appendTo($("#google_image_items"));box.unbind().bind("click",function(){$(".image_item_selected").removeClass('image_item_selected');$(this).addClass('image_item_selected')});var newImage=$("").appendTo(box);newImage.bind("load",function(){$(this).css("margin-top",(140-$(this).height())/2)})},setShapeImage:function(fileId,w,h){if(this.imageSelectedCallback){this.imageSelectedCallback(fileId,w,h)}$("#image_dialog").dlg("close")},fetchingRequest:null,setShapeImageByURL:function(url){$("#set_image_text").removeClass("errored").text("正在应用图片,请稍候...");$("#set_image_submit").button("disable");UI.fetchingRequest=$.ajax({url:"/user_image/reference",data:{url:url},success:function(result){if(result.result=="exception"){$("#set_image_text").addClass("errored").html("无法使用此图片,请选择其他图片")}else{$("#set_image_text").empty();var img=result.image;UI.setShapeImage(img.fileId,img.imageW,img.imageH)}}})},insertImage:function(fileId,w,h){w=parseInt(w);h=parseInt(h);var layout=$("#designer_layout");var centerX=layout.width()/2+layout.offset().left;var centerY=layout.height()/2+layout.offset().top;var pos=Utils.getRelativePos(centerX,centerY,$("#designer_canvas"));var shape=Model.create("standardImage",pos.x.restoreScale()-w/2,pos.y.restoreScale()-h/2);shape.props.w=w;shape.props.h=h;shape.fillStyle={type:"image",fileId:fileId,display:"fill",imageW:w,imageH:h};Model.add(shape);Designer.painter.renderShape(shape);Utils.unselect();Utils.selectShape(shape.id)},doOutputProcess:function(){},doPreview:function(){if($("#saving_tip").text()!="已保存成功"&&$("#saving_tip").text()!="保存成功"&&$("#saving_tip").text()!="您的文件已经成功保存"&&$("#saving_tip").text()!=""){if(editable){$.simpleAlert('页面中有未保存的内容,请先保存');return}}$.simpleAlert('请稍后','loading');$.post("./jd",{cmd:"com.actionsoft.apps.coe.pal_pl_repository_df",sid:sid,"uuid":chartId},function t(msg){$("#previewContent .procImg").remove();if(typeof(msg)=="string"){msg=eval('('+msg+')')}msg=msg.data.url;if(msg==""){alert("请您先保存一个版本!")}else{var img=$("");var hh=img.width();$("#previewContent").append(img)}$("#previewDialog").dialog({title:"预览",width:window.innerWidth*0.9,height:window.innerHeight*0.92});$.simpleAlert("close")},"text")},saveImage:function(){if($("#saving_tip").text()!="已保存成功"&&$("#saving_tip").text()!="保存成功"&&$("#saving_tip").text()!="您的文件已经成功保存"&&$("#saving_tip").text()!=""){if(editable){$.simpleAlert('页面中有未保存的内容,请先保存');return}}$.simpleAlert('请稍后','loading');$.ajax({type:"POST",url:"./jd",data:{sid:sid,cmd:"com.actionsoft.apps.coe.pal_pl_repository_image_save",uuid:chartId},success:function(r,textStatus,jqXHR){if(r.result=='ok'){$.simpleAlert("close");$.simpleAlert('图片创建完成','ok',2000,{callback:function(){var options={title:"提示",content:"是否打开图片预览",onConfirm:function(){$.simpleAlert("close");UI.doPreview()},onCancel:function(){}};$.confirm(options)}})}else{console.log(r);$.simpleAlert("close");$.simpleAlert(r.data.desc,'error')}},error:function(jqXHR,textStatus,errorThrown){$.simpleAlert(errorThrown,'err');console.log(jqXHR)console.log(textStatus)console.log(errorThrown)}})},showVersionCompare:function(){$("#dialog_version_compare").dialog({buttons:[{text:'确定',cls:"blue",handler:function(){var checkboxs=$("input[name='version']:checked");var numCheck=checkboxs.length;if(numCheck!=2){$.simpleAlert("请选择两个需要对比的版本","warning");return}var firstId;var secondId;var values=[];var names=[];checkboxs.each(function(){values.push($(this).val());names.push($(this).data("name"))});firstId=values[0];secondId=values[1];awsui.ajax.post("./jd?sid="+sid+"&cmd=com.actionsoft.apps.coe.pal_pl_version_compare",{firstId:firstId,secondId:secondId},function(data){$("#dialog_version_compare").dialog("close");var fileAttrCompare=data.fileAttrCompare;var shapeAttrCompare=data.shapeAttrCompare;var fileHtml="";var shapeHtml="";if(fileAttrCompare.length>0){for(var i=0;i"}$("#fileAttr").html(fileHtml)}if(shapeAttrCompare.length>0){for(var i=0;i"}$("#shapeAttr").html(shapeHtml)}$("#versionCompareResult").show();$("#dialog_version_compare_result").dialog({})},'json')}}]})},processExport:function(){if($("#saving_tip").text()!="已保存成功"&&$("#saving_tip").text()!="保存成功"&&$("#saving_tip").text()!="您的文件已经成功保存"&&$("#saving_tip").text()!=""){if(editable){$.simpleAlert('页面中有未保存的内容,请先保存');return}}var repositoryIds=[];repositoryIds.push(ruuid);var options={title:"提示",content:"确定导出并下载文件吗?",onConfirm:function(){$.simpleAlert('正在导出','loading');$.ajax({type:"POST",url:"./jd",data:{sid:sid,cmd:"com.actionsoft.apps.coe.pal_pl_export_handle",repositoryIds:JSON.stringify(repositoryIds)},success:function(r,textStatus,jqXHR){if(r.result=='ok'){$.simpleAlert("close");$.simpleAlert('导出完成','ok',2000,{callback:function(){$.simpleAlert("close");$.ajax({type:"POST",url:"./jd",data:{sid:sid,cmd:"com.actionsoft.apps.coe.pal_pl_export",exportTitle:r.data.exportTitle,exportCount:r.data.exportCount,dcId:r.data.dcId,},success:function(r,textStatus,jqXHR){if(r.result=='ok'){window.location.href=r.data.downLoadUrl}else{console.log(r)}},error:function(jqXHR,textStatus,errorThrown){$.simpleAlert(errorThrown,'err');console.log(jqXHR)console.log(textStatus)console.log(errorThrown)}})}})}else{console.log(r);$.simpleAlert("close")}},error:function(jqXHR,textStatus,errorThrown){$.simpleAlert(errorThrown,'err');console.log(jqXHR)console.log(textStatus)console.log(errorThrown)}})},onCancel:function(){}};$.confirm(options)},openNewPage:function(){window.open(location.href)},doExport:function(){if($("#saving_tip").text()!="已保存成功"&&$("#saving_tip").text()!="保存成功"&&$("#saving_tip").text()!="您的文件已经成功保存"&&$("#saving_tip").text()!=""){if(editable){$.simpleAlert('页面中有未保存的内容,请先保存');return}}$.simpleAlert('请稍后','loading');var type=$('input[name="type"]:checked').val();$.post("./jd",{cmd:"com.actionsoft.apps.coe.pal_pl_repository_download_png",sid:sid,"uuid":chartId,type:type},function t(msg){if(typeof(msg)=="string"){msg=eval('('+msg+')')}msg=msg.data.url;if(msg==""){alert("请您先保存一个版本!")}else{$("#export_iframe").attr("src",msg)}$.simpleAlert("close")},"text");$('#export_dialog').dlg('close')},showHotKey:function(){var height=$(window).height()-175;if(height>500){height=500+"px"}$("#hotkey_list").dlg();$("#hotkey_list").css({"top":"28px"});$("#hotkey_list .dialog_content").css({"height":height})},showFeedBack:function(){$("#send_feedback").css({width:"auto",height:"auto"});var sendFeedBack=$("#send_feedback");sendFeedBack.dlg();$("#feedback_email").focus();$("#feedback_message").val("");$(".feedback_error_email_format").hide();$(".feedback_error_msg").hide()},sendFeedBack:function(dom){$(".feedback_error_email_format").hide();$(".feedback_error_msg").hide();var email=$.trim($("#feedback_email").val());var reg=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;if(!reg.test(email)){$("#feedback_email").focus();$(".feedback_error_email_format").show();return}var feedbackMessage=$.trim($("#feedback_message").val());if(feedbackMessage==""){$("#feedback_message").val("").focus();$(".feedback_error_msg").show();return}Util.ajax({url:"/support/save_ask",data:{content:feedbackMessage,username:$("#feedback_name").val(),email:email,url:location.href},success:function(data){$(".dlg_mask").remove();$("#send_feedback").animate({left:$(window).width(),top:$(window).height(),width:0,height:0,opacty:0.2})}})},gettingStart:function(delay){this.showStartStep(1)},showStartStep:function(step,dom){$(".mark_content").hide();var content=$(".mark"+step+"_content");content.show();var top;var left;if(step==1){top=$("#shape_panel").offset().top+70;left=$("#shape_panel").offset().left+$("#shape_panel").width()+10}else if(step==2){top=$(".row2").offset().top+30;left=$("#menu_bar_insert").offset().left+$("#menu_bar_insert").width()-content.outerWidth()/2}else if(step==3){top=$(".toolbar").offset().top+40;left=270}else if(step==4){top=$("#dock").offset().top+10;left=$("#dock").offset().left-content.outerWidth()-10}else if(step=="created"){top=dom.offset().top+dom.height()/2-content.outerHeight()/2;if(top<=0){top=0}if(top+content.outerHeight()>$(window).height()){top=$(window).height()-content.outerHeight()}left=dom.offset().left+dom.width()+10}content.css({top:top,left:left})},closeGettingStart:function(dom){$(".mark_content").hide()},showAddColla:function(){Util.ajax({url:"/collaboration/get_colla_role_list",data:{chartId:chartId},success:function(data){$("#colla_dialog").find(".role_list").html(data).scrollTop(999);$("#colla_dialog").removeClass("_update");$("#colla_dialog").css({"top":($(window).height()-$("#colla_dialog").outerHeight())*0.5+"px"});$("#colla_dialog").dlg();$("#colla_suggest_box").empty();$("#add_prompt4").hide();$("#add_prompt3").hide();$("#add_prompt2").hide();$("#add_prompt1").show()}});var lastVal="";$("#input_add_colla").val("").unbind().bind("keyup",function(){var value=$(this).val();if(value==lastVal){return}lastVal=value;if(value==""){$("#colla_suggest_box").empty();$("#add_prompt4").hide();$("#add_prompt3").hide();$("#add_prompt2").hide();$("#add_prompt1").show();return}Util.ajax({url:"/collaboration/get_new_members",data:{value:value},success:function(data){$("#colla_suggest_box").html(data);if($("#colla_suggest_box").find("ul").length>0){$("#add_prompt4").hide();$("#add_prompt3").hide();$("#add_prompt2").show();$("#add_prompt1").hide()}else{$("#add_prompt4").hide();$("#add_prompt3").hide();$("#add_prompt2").hide();$("#add_prompt1").show()}$(".colla_suggest").find("li").unbind().bind("click",function(){$("#add_prompt4").hide();$("#add_prompt3").hide();$("#add_prompt2").show();$("#add_prompt1").hide();var value=$.trim($("#input_add_colla").val());$(".colla_suggest").find("li").removeClass("seled");$(this).addClass("seled");var type=$(this).attr("joinType");var target=$(this).attr("target");if(type=="user"){var userName=$(this).attr("username");$("#input_add_colla").val(userName);$("#add_userid").val(target)}else{$("#input_add_colla").val(target);$("#add_userid").val(target)}$("#add_type").val(type)})}})})},doAddCollaboration:function(){if($(".colla_suggest").length>0){if($(".colla_suggest").find(".seled").length==0){$("#add_prompt1").hide();$("#add_prompt2").show();$("#add_prompt3").hide();$("#add_prompt4").hide();var top=($(window).outerHeight()-104)*0.5+100;var left=($(window).outerWidth()-272)*0.5;$("#confirm_dlg").removeClass("newSize").css({top:top+"px",left:left+"px"});$("#confirm_dlg").addClass("newSize").css({top:($(window).outerHeight()-$("#confirm_dlg").height())*0.5+"px",left:($(window).outerWidth()-$("#confirm_dlg").width())*0.5+"px",display:"block"})}else{var imgSrc=$(".colla_suggest").find(".seled").find("img").attr("src");var userFullName=$("#input_add_colla").val();if(userFullName.length>30){userFullName=userFullName.substr(0,30)+"..."}var target=$("#add_userid").val();var role=$("#invit_role").val();var type=$("#add_type").val();$(".add_new_button").find(".designer_button").text("<@i18n resource='diagraming.collaboation_sending'/>");var target_item=null;if(type=="email"){$(".role_list").find(".role_item").each(function(){if($(this).attr("type")==type&&$(this).attr("target")==target){target_item=$(this);$(this).find(".inviting_").text("<@i18n resource='diagraming.collaboation_inviting_again'/>")}})}var paramOuter={type:type,target:target,role:role,chartId:chartId};Util.ajax({url:"/collaboration/add",data:paramOuter,success:function(data){var result=data.result;if(result=="exists"){$("#add_prompt2").hide();$("#add_prompt1").hide();$("#add_prompt4").hide();$("#add_prompt3").show()}else{Util.ajax({url:"/collaboration/get_colla_role_list",data:{chartId:chartId},success:function(data){$(".role_list").html(data).scrollTop(999)}})}$(".add_new_button").find(".designer_button").text("<@i18n resource='diagraming.collaboation_send_invitation'/>");$("#colla_dialog").addClass("_update").css({top:($(window).height()-$("#colla_dialog").outerHeight())*0.5+"px"});if(result!="exists"){setTimeout(function(){$("#add_prompt3").hide();$("#add_prompt2").hide();$("#add_prompt1").hide();$("#add_prompt4").show()},400)}setTimeout(function(){$("#add_prompt3").hide();$("#add_prompt2").hide();$("#add_prompt4").hide();$("#add_prompt1").show();$("#input_add_colla").val("");$("#colla_suggest_box").html("")},1000)}})}}},deleteCollaRole:function(dom){var parent=$(dom).parent(".role_item");var collaborationId=parent.attr("collaborationId");Util.ajax({url:"/collaboration/delete",data:{collaborationId:collaborationId},success:function(data){if(data.result=="success")parent.remove()}});$("#colla_dialog").addClass("_update").css({top:($(window).height()-$("#colla_dialog").outerHeight())*0.5+"px"})},changeCollaRole:function(collaborationId,dom){Util.ajax({url:"/collaboration/set_role",data:{collaborationId:collaborationId,role:$(dom).val()},success:function(data){if(data.result=="success"){$(dom).parent(".given_role").find(".change_success").stop().animate({"left":"-38px"},200).delay(400).animate({"left":"0px"},200)}}})},showShapesManage:function(){var $dialog=$("#shapes_dialog").dialog({buttons:[{text:'确定',cls:"blue",handler:UI.saveShapesManage},{text:'关闭',handler:function(){$dialog.dialog("close")}}]});$("#shape_manage_list").children("li").unbind().bind("click",function(){var chkbox=$(this).find("input");var checked=!chkbox.is(":checked");chkbox.attr("checked",checked);cateChanged(chkbox)});$("#shape_manage_list").find("input").unbind().bind("click",function(e){e.stopPropagation();cateChanged($(this))});function cateChanged(chk){var value=chk.val();var arr=value.split(",");var chked=chk.is(":checked");if(arr.length>1){$("#shape_manage_list").find("input").each(function(){var cate=$(this).val();if(arr.indexOf(cate)>=0){$(this).attr("checked",chked)}})}else{$("#shape_manage_list").find(".cate_parent").each(function(){var cates=$(this).val().split(",");var allChked=true;for(var i=0;i8){dialogHeight=340+(taskList.length-8)*26}if(dialogHeight>($(window).height()-80)){dialogHeight=($(window).height()-80)}dialogHTML+='';$(document.body).append(dialogHTML);$("#activityNoDialog").dialog({onClose:function(){$('#activityNoDialog').remove();$('#row-drag-obj').remove()},buttons:[{text:'确定',cls:"blue",handler:function(){if(activityNoArr.length>0){var allRows=activityNoGrid.awsGrid('getAllRows');for(var shapeId in Model.define.elements){var shape=Model.getShapeById(shapeId);for(var x=0;x0){for(var j=0;j
          不支持编号排序画布没有形状或者形状没有编号属性
          '));awsuiMessagePage();return}var activityNoGridOptions={width:317,height:dialogHeight-100,flexWidth:false,flexHeight:false,resizable:false,selectionModel:{type:"none",model:"single"},scrollModel:{vertical:true,horizontal:false},bottomVisible:false,rowDrag:true};activityNoGridOptions.colModel=[{title:"名称",width:200,align:'left',dataType:'string',dataIndx:'name',resizable:false,sortable:false},{title:"节点号",width:80,align:'center',dataType:'integer',dataIndx:'no',resizable:false,sortable:false}];activityNoGridOptions.dataModel={data:activityNoArr,location:"local",sorting:"local",sortIndx:"no",sortDir:"up"};var activityNoGrid=$("#activityNoGrid").awsGrid(activityNoGridOptions);activityNoGrid.awsGrid('option','rowDragCallback',function(source,target){return true});activityNoGrid.awsGrid('option','rowDragSuccessCallback',function(source,target){var allRows=activityNoGrid.awsGrid('getAllRows');for(var i=0;i0){for(var j=0;j0){$("#page_size_list").dropdown("select",item)}else{$("#page_size_list").dropdown("select",$("#dock_size_custom"))}$("#dock_size_w").spinner("setValue",Model.define.page.width+"px");$("#dock_size_h").spinner("setValue",Model.define.page.height+"px")}});$("#dock_size_w").spinner({min:200,unit:"px",step:100,onChange:function(val){Designer.setPageStyle({width:val})}});$("#dock_size_h").spinner({min:200,unit:"px",step:100,onChange:function(val){Designer.setPageStyle({height:val})}});$("#dock_page_padding").button({onMousedown:function(){$("#page_padding_list").dropdown({target:$("#dock_page_padding"),onSelect:function(item){var p=parseInt(item.attr("p"));Designer.setPageStyle({padding:p})$("#dock_page_padding").button("setText",item.text())}});var item=$("#page_padding_list").children("li[p="+Model.define.page.padding+"]");$("#page_padding_list").dropdown("select",item)}});$("#dock_page_color").colorButton({position:"center",onSelect:function(color){Designer.setPageStyle({backgroundColor:color})}});$("#dock_page_showgrid").bind("change",function(){var showGrid=$(this).is(":checked");Designer.setPageStyle({showGrid:showGrid});if(showGrid){$("#dock_gridsize_box").show()}else{$("#dock_gridsize_box").hide()}});$("#dock_page_gridsize").button({onMousedown:function(){$("#page_gridsize_list").dropdown({target:$("#dock_page_gridsize"),onSelect:function(item){var s=parseInt(item.attr("s"));Designer.setPageStyle({gridSize:s})$("#dock_page_gridsize").button("setText",item.text())}});var item=$("#page_gridsize_list").children("li[s="+Model.define.page.gridSize+"]");$("#page_gridsize_list").dropdown("select",item)}});$("#spinner_play_speed").spinner({min:1,max:30,unit:"s",step:1,value:5,onChange:function(val){}});$("#spinner_play_speed").spinner("setValue","2s");$("#btn_history_play").button({onClick:function(){if($("#btn_history_play").children().hasClass("ico_pause")){Dock.pauseVersions()}else{Dock.playVersions()}}});$("#btn_history_restore").button({onClick:function(){Dock.restoreVersion()}})},currentView:"",showView:function(name){if($("#dock_btn_"+name).button("isDisabled")){return}$(".dock_view").hide();$(".dock_view_"+name).show();$(".dock_buttons").children().removeClass("selected");$("#dock_btn_"+name).addClass("selected");if(Dock.currentView=="history"&&name!="history"){Dock.closeHistory()}this.currentView=name;this.update(true)},setFillStyle:function(fillStyle){$("#dock_fill_type").button("setText",$("#dock_fill_list").children("li[ty="+fillStyle.type+"]").text());$(".fill_detail").hide();if(fillStyle.type=="solid"){$(".fill_detail_solid").show();$("#fill_solid_btn").colorButton("setColor",fillStyle.color)}else if(fillStyle.type=="gradient"){$(".fill_detail_gradient").show();$("#fill_gradient_begin").attr("c",fillStyle.beginColor).colorButton("setColor",fillStyle.beginColor);$("#fill_gradient_end").attr("c",fillStyle.endColor).colorButton("setColor",fillStyle.endColor);$("#gradient_type").button("setText",$("#gradient_type_list").children("li[ty="+fillStyle.gradientType+"]").text());$(".gradient_details").hide();if(fillStyle.gradientType=="linear"){$("#gradient_type_linear").show();$("#gradient_angle").spinner("setValue",Math.round(fillStyle.angle/Math.PI*180)+"°")}else{$("#gradient_type_radial").show();$("#gradient_radius").spinner("setValue",Math.round(fillStyle.radius*100)+"%")}}else if(fillStyle.type=="image"){$(".fill_detail_image").show();var display="fill";if(fillStyle.display){display=fillStyle.display}$("#fill_img_display").button("setText",$("#img_display_list").children("li[ty="+display+"]").text())}},update:function(drawNav){if(this.currentView=="portalAttrShow"||this.currentView=="portalDescShow"||this.currentView=="portalFileShow"){changeArributeByShape()}if(this.currentView=="navigator"){if(drawNav){Navigator.draw()}$("#dock_zoom").spinner("setValue",Math.round(Designer.config.scale*100)+"%")}else if(this.currentView=="graphic"){var selectedIds=Utils.getSelectedIds();var count=selectedIds.length;var shapeIds=Utils.getSelectedShapeIds();var shapeCount=shapeIds.length;if(count==0){$("#dock_line_color").button("disable");$("#dock_line_style").button("disable");$("#dock_line_width").button("disable")}else{$("#dock_line_color").button("enable");$("#dock_line_style").button("enable");$("#dock_line_width").button("enable");var shape=Model.getShapeById(selectedIds[0]);$("#dock_line_color").colorButton("setColor",shape.lineStyle.lineColor);var lineStyleCls=$("#line_style_list").children("li[line="+shape.lineStyle.lineStyle+"]").children().attr("class");$("#dock_line_style").children(".linestyle").attr("class",lineStyleCls);$("#dock_line_width").spinner("setValue",shape.lineStyle.lineWidth+"px")}if(shapeCount==0){$("#dock_fill_type").button("disable");$("#spinner_opacity").button("disable");Dock.setFillStyle({type:"none"})}else{$("#dock_fill_type").button("enable");$("#spinner_opacity").button("enable");var shape=Model.getShapeById(shapeIds[0]);Dock.setFillStyle(shape.fillStyle);$("#spinner_opacity").spinner("setValue",Math.round(shape.shapeStyle.alpha/1*100)+"%")}}else if(this.currentView=="metric"){var shapeIds=Utils.getSelectedShapeIds();var shapeCount=shapeIds.length;if(shapeCount==0){$("#dock_metric_x").button("disable");$("#dock_metric_w").button("disable");$("#dock_metric_y").button("disable");$("#dock_metric_h").button("disable");$("#dock_metric_angle").button("disable")}else{var shape=Model.getShapeById(shapeIds[0]);$("#dock_metric_x").button("enable").spinner("setValue",Math.round(shape.props.x)+"px");$("#dock_metric_w").button("enable").spinner("setValue",Math.round(shape.props.w)+"px");$("#dock_metric_y").button("enable").spinner("setValue",Math.round(shape.props.y)+"px");$("#dock_metric_h").button("enable").spinner("setValue",Math.round(shape.props.h)+"px");$("#dock_metric_angle").button("enable").spinner("setValue",Math.round(shape.props.angle/Math.PI*180)+"°")}}else if(this.currentView=="page"){var page=Model.define.page;var w=page.width;var h=page.height;var sizeItem=$("#page_size_list").children("li[w="+w+"][h="+h+"]");var sizeText="";if(sizeItem.length>0){sizeText=sizeItem.text()}else{sizeText=$("#dock_size_custom").text()}$("#dock_page_size").button("setText",sizeText);$("#dock_page_padding").button("setText",page.padding+"px");$("#dock_page_color").colorButton("setColor",page.backgroundColor);$("#dock_page_showgrid").attr("checked",page.showGrid);if(page.showGrid){$("#dock_gridsize_box").show()}else{$("#dock_gridsize_box").hide()}var gridText="";var gridItem=$("#page_gridsize_list").children("li[s="+page.gridSize+"]");if(gridItem.length>0){var gridText=gridItem.text()}$("#dock_page_gridsize").button("setText",gridText)}else if(this.currentView=="attribute"){if(!inputUpdate){changeArributeByShape()}if(role=="viewer"){$("#dock_page_attribute table input").prop("disabled",true);$("#tagContent1 table input, #tagContent1 table textarea").prop("disabled",true)}}else if(this.currentView=="message"){$.ajax({url:"./jd?sid="+$("#sid").val()+"&cmd=com.actionsoft.apps.coe.pal_pl_repository_commentlist&repositoryId="+ruuid+"&openAppType="+openAppType,success:function(msg){var html="";var array;if(typeof(msg)=="string"){array=eval('('+msg+')').msg}else{array=msg.msg}if(typeof(array)=="string"){array=eval('('+array+')')}for(var i=0;i0){for(var i=0;i "}}else{html="
          暂无发布历史
          "}$("#sidePublishListDiv article").html(html)}})}else if(this.currentView=="link"){$.ajax({url:"./jd?sid="+$("#sid").val()+"&cmd=com.actionsoft.apps.coe.pal_link_of_repository&wsId="+$("#wsId").val()+"&plId="+ruuid,success:function(r){var links=r.data.links;var customLinks=r.data.customLInks;var html="";var flag1=false;var flag2=false;if(links!=null&&links.length>0){html+='

          文件链接

          ';for(var i=0;i'}}else{flag1=true}if(customLinks!=null&&customLinks.length>0){html+='

          自定义链接

          ';html+=''}else{flag2=true}if(flag1&&flag2){html="
          暂无链接
          "}$("#linkContent").empty().html(html)}})}else if(this.currentView=='diff'){var html=''$.ajax({url:"./jd?sid="+$("#sid").val()+"&cmd=com.actionsoft.apps.coe.pal_repository_model_version_diff_query&wsId="+$("#wsId").val()+"&id="+ruuid,success:function(ro){if(ro.result=="ok"){var diffContent=ro.data;for(var i=0;i'}diffListHtml+='
          '+content[j].title+'
          '+diffDetailHtml+'
          '}html+=''+diffContent[i].versionName+''+diffContent[i].updateTime+'('+diffCount+'处修改)'+diffListHtml+''}$("#diffTable").empty().html(html)}else{html=''+ro.msg+''$("#diffTable").empty().html(html)}}})}if(this.currentView=="history"){if(drawNav&&Dock.historyVersions==null){this.loadHistorys()}}},historyVersions:null,loadHistorys:function(){},resetVersions:function(){$("#history_versions").children("li").unbind().bind("click",function(){if(Dock.playingTimeout!=null){return}if($(this).hasClass("selected")){Dock.closeHistory()}else{$("#history_versions").children(".selected").removeClass("selected");$(this).addClass("selected");var defId=$(this).attr("def");Dock.showHistoryVersion(defId)}var current=$("#history_versions").children(".selected");if(current.length!=0&¤t.attr("ind")!="0"){$("#spinner_play_speed").button("enable");$("#btn_history_play").button("enable");$("#btn_history_restore").button("enable")}else{$("#spinner_play_speed").button("disable");$("#btn_history_play").button("disable");$("#btn_history_restore").button("disable")}});$("#history_versions").height("auto");var top=$("#history_versions").offset().top;var bottom=top+$("#history_versions").height()+75;if(bottom>$(window).height()){var height=$(window).height()-top-75;if(height<140){height=140}$("#history_versions").height(height)}else{$("#history_versions").height("auto")}},editHistoryRemark:function(event,versionId){event.stopPropagation();var versionDom=$("#history_versions").children("li[vid="+versionId+"]");versionDom.find(".remark_container").hide();var currentRemark=versionDom.find(".remark_text").text();var editContainer=versionDom.find(".edit_container");editContainer.show();editContainer.children("textarea").val(currentRemark).select();editContainer.children(".save").bind("click",function(e){e.stopPropagation();var newRemark=editContainer.children("textarea").val();versionDom.find(".remark_text").text(newRemark);versionDom.find(".remark_container").show();editContainer.hide();if(newRemark!=currentRemark){CLB.send({action:"versionRemark",remark:newRemark,versionId:versionId})}});editContainer.children(".cancel").bind("click",function(e){e.stopPropagation();Dock.cancelHistoryRemark()})},cancelHistoryRemark:function(){$(".remark_container").show();$(".edit_container").hide()},showHistoryVersion:function(defId){$("#spinner_play_speed").button("disable");$("#btn_history_play").button("disable");$("#btn_history_restore").button("disable");Dock.cancelHistoryRemark();$.ajax({url:"/diagraming/getdefinition",data:{definitionId:defId},success:function(data){Dock.openHistory(data.definition);if($("#history_versions").children(".selected").attr("ind")!="0"){$("#spinner_play_speed").button("enable");$("#btn_history_play").button("enable");$("#btn_history_restore").button("enable")}}})},playVersions:function(){var current=$("#history_versions").children(".selected");var index=parseInt(current.attr("ind"));Dock.playOneVersion(index--,0);$("#btn_history_play").children().attr("class","ico ico_pause");$("#btn_history_play").attr("title","暂停").trigger("mouseenter");$("#btn_history_restore").button("disable")},pauseVersions:function(){if(this.playingTimeout){clearTimeout(this.playingTimeout)}this.playingTimeout=null;$("#btn_history_play").children().attr("class","ico ico_play");$("#btn_history_play").attr("title","从此版本播放");$(".ico_playing").remove();var current=$("#history_versions").children(".selected");$("#history_versions").children(".playing").removeClass("playing");if(current.length!=0&¤t.attr("ind")!="0"){$("#spinner_play_speed").button("enable");$("#btn_history_play").button("enable");$("#btn_history_restore").button("enable")}else{$("#spinner_play_speed").button("disable");$("#btn_history_play").button("disable");$("#btn_history_restore").button("disable")}},playingTimeout:null,playOneVersion:function(index,msgIndex){var current=$("#history_versions").children("li[ind="+index+"]");$("#history_versions").children(".selected").removeClass("selected");current.addClass("selected").addClass("playing");$(".ico_playing").remove();current.append("
          ");var version=Dock.historyVersions.versions[index];var messageStr=version.messages[msgIndex];var messages=JSON.parse(messageStr);MessageSource.receive(messages);var top=current.position().top;if(top<0){$("#history_versions").scrollTop($("#history_versions").scrollTop()+top)}var time=$("#spinner_play_speed").spinner("getValue")*1000;if(index==0&&msgIndex==version.messages.length-1){this.pauseVersions()}else{if(msgIndex
          "+attr.name+"
          "+typeText+"
          "+attr.value+"
          ").appendTo($(".attr_list"));if(attr.category!="default"){item.append("
          ")}}}this.fitAttrList()},fitAttrList:function(){var scroll=$("#tagContent").scrollTop();$("#tagContent").height("auto");var top=$("#tagContent").offset().top;var bottom=top+$(".clearfix").height()+10;if(bottom>$(window).height()){var height=$(window).height()-top-10;if(height<140){height=140}$("#tagContent").height(height)}else{$("#tagContent").height("auto")}$("#tagContent").scrollTop(scroll)},showAttrAdd:function(){$("#attr_add_btn").hide();$(".attr_add_items").show();$("#attr_add_name").val("").focus();$("#attr_add_type").val("string");$("#attr_add_type").unbind().bind("change",function(){Dock.setAttrValueInput(null,$(this).val())});Dock.setAttrValueInput(null,"string");this.fitAttrList()},saveAttrAdd:function(){var name=$("#attr_add_name").val();if(name==""){$("#attr_add_name").focus();return}var type=$("#attr_add_type").val();var value=$("#attr_add_value_arera").children().val();var newAttr={name:name,type:type,value:value};Designer.addDataAttribute(newAttr);this.setAttributeList();this.showAttrAdd()},cancelAttrAdd:function(){$("#attr_add_btn").show();$(".attr_add_items").hide();this.fitAttrList()},editAttr:function(attrId){var item=$(".attr_item_"+attrId);if(item.hasClass("attr_editing")){return}if($(".attr_editing").length>0){var editingId=$(".attr_editing").attr("id");this.saveAttrEdit(editingId)}item=$(".attr_item_"+attrId);item.addClass("attr_editing");var attr=Designer.getDataAttrById(attrId);var input=this.setAttrValueInput(attr,attr.type);input.val(attr.value).select();if(attr.category!="default"){var nameDiv=item.children(".attr_name");nameDiv.empty();var nameInput=$("").appendTo(nameDiv);nameInput.val(attr.name).select();var typeDiv=item.children(".attr_type");typeDiv.empty();var select=$("").appendTo(typeDiv);select.html($("#attr_add_type").html()).val(attr.type);select.bind("change",function(){Dock.setAttrValueInput(attr,$(this).val())})}var displayArea=$("
          ").appendTo(item);displayArea.append("
          <@i18n resource='diagraming.addattr.displayas'/>
          ");displayArea.append("
          ");displayArea.append("
          ");displayArea.append("
          ");this.appendDisplayItems();var showType="none";if(attr.showType){showType=attr.showType}this.setAttrDisplay(showType);$("#attr_edit_showtype").attr("ty",showType).button({onMousedown:function(){$("#attr_display_list").dropdown({target:$("#attr_edit_showtype"),onSelect:function(item){var type=item.attr("ty");$("#attr_edit_showtype").attr("ty",type).button("setText",item.text());Dock.setAttrDisplay(type)}});var type=$("#attr_edit_showtype").text().trim();$("#attr_display_list").children().each(function(){if($(this).text()==type){$("#attr_display_list").dropdown("select",$(this));return false}})}});$("#attr_edit_showtype").attr("ty",showType).button("setText",$("#attr_display_list").children("li[ty="+showType+"]").html());if(showType!="none"){$("#attr_display_name").attr("checked",attr.showName);if(showType=="icon"){this.setAttrIcon(attr.icon)}}var horizontal="mostright";if(attr.horizontal){horizontal=attr.horizontal}var vertical="mostbottom";if(attr.vertical){vertical=attr.vertical}$("#attr_location_h").button("setText",$("#attr_location_h_list").children("li[loc="+horizontal+"]").html());$("#attr_location_h").attr("loc",horizontal);$("#attr_location_v").button("setText",$("#attr_location_v_list").children("li[loc="+vertical+"]").html());$("#attr_location_v").attr("loc",vertical);item.append("
          <@i18n resource='global.ok'/>
          <@i18n resource='global.cancel'/>
          ");$("#save_edit_attr").bind("click",function(e){e.stopPropagation();Dock.saveAttrEdit(attrId)});$("#cancel_edit_attr").bind("click",function(e){e.stopPropagation();Dock.setAttributeList()})},setAttrValueInput:function(attr,type){var valueArea;if(attr!=null){valueArea=$(".attr_editing").children(".attr_value")}else{valueArea=$("#attr_add_value_arera")}valueArea.empty();var result;if(type=="boolean"){result=$("").appendTo(valueArea)}else if(type=="list"){result=$("").appendTo(valueArea);if(attr.listItems){for(var i=0;i"+listItem+"")}}}else{result=$("").appendTo(valueArea)}if(attr==null){valueArea.children().css("width","260px")}else{valueArea.children().css("width","128px")}return result},appendDisplayItems:function(){var optionsArea=$(".attr_display_options");var detailArea=$("
          ").appendTo(optionsArea);detailArea.append("");var iconButtonArea=$("
          ").appendTo(detailArea);iconButtonArea.append("
          <@i18n resource='diagraming.addattr.icon'/>
          ");iconButtonArea.append("
          ");iconButtonArea.append("
          ");if($("#attr_icon_list").children("li").html()==""){var html="";var index=1;while(index<=49){if(index==30){html+="
          "}html+="
          ";index++}$("#attr_icon_list").children("li").html(html)}var locationArea=$("
          ").appendTo(optionsArea);locationArea.append("
          <@i18n resource='diagraming.addattr.display.location'/>
          ");locationArea.append("
          <@i18n resource='diagraming.addattr.display.h'/>
          ");locationArea.append("
          Most Right
          ");locationArea.append("
          ");locationArea.append("
          <@i18n resource='diagraming.addattr.display.v'/>
          ");locationArea.append("
          Most Bottom
          ");locationArea.append("
          ");optionsArea.append("
          ");$("#attr_display_icon").button({onMousedown:function(){$("#attr_icon_list").dropdown({target:$("#attr_display_icon")})}});$("#attr_location_h").button({onMousedown:function(){$("#attr_location_h_list").dropdown({target:$("#attr_location_h"),onSelect:function(item){$("#attr_location_h").button("setText",item.html());$("#attr_location_h").attr("loc",item.attr("loc"))}})}});$("#attr_location_v").button({onMousedown:function(){$("#attr_location_v_list").dropdown({target:$("#attr_location_v"),onSelect:function(item){$("#attr_location_v").button("setText",item.html());$("#attr_location_v").attr("loc",item.attr("loc"))}})}})},setAttrDisplay:function(type){if(type=="none"){$(".attr_display_options").hide()}else{$(".attr_display_options").show();if(type=="icon"){$("#attr_icon_area").show()}else{$("#attr_icon_area").hide()}}},setAttrIcon:function(icon){$("#attr_display_icon").attr("ico",icon).button("setText","");if(icon){$("#attr_display_icon").button("setText","")}},saveAttrEdit:function(attrId){var item=$(".attr_item_"+attrId);if(!item.hasClass("attr_editing")){return}var attr=Designer.getDataAttrById(attrId);if(attr.category!="default"){var name=item.children(".attr_name").children("input").val();if(name==""){item.children(".attr_name").children("input").focus();return}attr.name=name;attr.type=item.children(".attr_type").children("select").val()}attr.value=item.children(".attr_value").children().val();var showType=$("#attr_edit_showtype").attr("ty");attr.showType=showType;if(showType!="none"){attr.showName=$("#attr_display_name").is(":checked");attr.horizontal=$("#attr_location_h").attr("loc");attr.vertical=$("#attr_location_v").attr("loc");if(showType=="icon"){attr.icon=$("#attr_display_icon").attr("ico")}}var selectedIds=Utils.getSelectedIds();var shape=Model.getShapeById(selectedIds[0]);if(attr.category=="default"&&shape.category=="bpmn"){if(!shape.attribute){shape.attribute={}}if(!shape.attribute.markers){shape.attribute.markers=[]}var markers=shape.attribute.markers;if(attr.name=="loopCharacteristics"){Utils.removeFromArray(markers,"loop");Utils.removeFromArray(markers,"sequential");Utils.removeFromArray(markers,"parallel");if(attr.value=="StandardLoopCharacteristics"){Utils.addToArray(markers,"loop")}else if(attr.value=="MultipleLoopCharacteristics"){var sequantial=Designer.getDefaultDataAttrByName("isSequantial");if(sequantial!=null){if(sequantial.value=="true"){Utils.addToArray(markers,"sequential")}else{Utils.addToArray(markers,"parallel")}}}}else if(attr.name=="isSequantial"){Utils.removeFromArray(markers,"sequential");Utils.removeFromArray(markers,"parallel");var loop=Designer.getDefaultDataAttrByName("loopCharacteristics");if(loop!=null&&loop.value=="MultipleLoopCharacteristics"){if(attr.value=="true"){Utils.addToArray(markers,"sequential")}else{Utils.addToArray(markers,"parallel")}}}else if(attr.name=="isForCompensation"){Utils.removeFromArray(markers,"compensation");if(attr.value=="true"){Utils.addToArray(markers,"compensation")}}else if(attr.name=="isCollection"||attr.name=="ParticipantMultiplicity"){Utils.removeFromArray(markers,"parallel");if(attr.value=="true"){Utils.addToArray(markers,"parallel")}}else if(attr.name=="loopType"){Utils.removeFromArray(markers,"loop");Utils.removeFromArray(markers,"sequential");Utils.removeFromArray(markers,"parallel");if(attr.value=="Standard"){Utils.addToArray(markers,"loop")}else if(attr.value=="MultiInstanceSequential"){Utils.addToArray(markers,"sequential")}else if(attr.value=="MultiInstanceParallel"){Utils.addToArray(markers,"parallel")}}}Designer.updateDataAttribute(attr);this.setAttributeList()},deleteAttr:function(attrId,event){event.stopPropagation();var item=$(".attr_item_"+attrId);item.remove();this.fitAttrList();Designer.deleteDataAttribute(attrId)},fullScreen:function(element,presentation){if(element.requestFullscreen){element.requestFullscreen()}else if(element.mozRequestFullScreen){element.mozRequestFullScreen()}else if(element.webkitRequestFullscreen){element.webkitRequestFullscreen()}else{if(presentation){$("#fullscreen_tip").find(".t").text("由于您的浏览器限制,无法进入演示视图。")}else{$("#fullscreen_tip").find(".t").text("无法进入全屏视图,您可以按(F11)进入。")}$("#fullscreen_tip").fadeIn()}},enterPresentation:function(){$("#designer").bind('webkitfullscreenchange',function(e){Dock.manageFullScreen()});$(document).bind('mozfullscreenchange',function(e){Dock.manageFullScreen()}).bind('fullscreenchange',function(e){Dock.manageFullScreen()});this.fullScreen(Utils.getDomById("designer"),true)},enterFullScreen:function(){this.fullScreen(document.documentElement)},manageFullScreen:function(){var designer=Utils.getDomById("designer");if(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement){$("#shape_panel").addClass("readonly");$("#designer_viewport").addClass("readonly");$(window).unbind("resize.designer");$("#designer_layout").height(window.screen.height);Designer.hotkey.cancel();Designer.op.cancel();$("#dock").hide();$(".dock_view").hide();Designer.contextMenu.destroy();Designer.op.canvasFreeDraggable()}else{$("#shape_panel").removeClass("readonly");$("#designer_viewport").removeClass("readonly");Designer.initialize.initLayout();Designer.hotkey.init();Designer.op.init();$("#dock").show();if(Dock.currentView!=""){Dock.showView(Dock.currentView)}Designer.contextMenu.init();$("#designer").unbind('webkitfullscreenchange');$("#designer").unbind('mozfullscreenchange').unbind('fullscreenchange')}}};var Navigator={init:function(){$("#designer_layout").bind("scroll",function(){Navigator.setView()});$("#navigation_eye").bind("mousedown",function(downE){var eye=$(this);var beginPos=eye.position();$("#designer_layout").unbind("scroll");var layout=$("#designer_layout");var beginTop=layout.scrollTop();var beginLeft=layout.scrollLeft();var designerCanvas=$("#designer_canvas");var canvasW=designerCanvas.width();var canvasH=designerCanvas.height();var canvas=$("#navigation_canvas");var navW=canvas.width();var navH=canvas.height();var scaleW=canvasW/navW;var scaleH=canvasH/navH;$(document).bind("mousemove.navigator",function(moveE){var offsetX=moveE.pageX-downE.pageX;var offsetY=moveE.pageY-downE.pageY;var newLeft=beginLeft+offsetX*scaleW;layout.scrollLeft(newLeft);var newTop=beginTop+offsetY*scaleH;layout.scrollTop(newTop);eye.css({left:beginPos.left+offsetX,top:beginPos.top+offsetY})});$(document).bind("mouseup.navigator",function(moveE){$(document).unbind("mousemove.navigator");$(document).unbind("mouseup.navigator");Navigator.setView();$("#designer_layout").bind("scroll",function(){Navigator.setView()})})});$("#navigation_canvas").bind("click",function(e){var pos=Utils.getRelativePos(e.pageX,e.pageY,$(this));var designerCanvas=$("#designer_canvas");var canvasW=designerCanvas.width();var canvasH=designerCanvas.height();var canvas=$("#navigation_canvas");var navW=canvas.width();var navH=canvas.height();var scaleW=canvasW/navW;var scaleH=canvasH/navH;var canvasX=pos.x*scaleW;var canvasY=pos.y*scaleH;var layout=$("#designer_layout");var margin=Designer.config.pageMargin;layout.scrollLeft(canvasX+margin-layout.width()/2);layout.scrollTop(canvasY+margin-layout.height()/2)});this.setView()},draw:function(){if(this.drawNavigationTimeout){window.clearTimeout(this.drawNavigationTimeout)}this.drawNavigationTimeout=setTimeout(function(){var canvas=$("#navigation_canvas");var ctx=canvas[0].getContext("2d");ctx.save();ctx.clearRect(0,0,canvas.width(),canvas.height());ctx.scale(canvas.width()/Model.define.page.width,canvas.height()/Model.define.page.height);for(var i=0;iviewW){visibleLeft=viewW}if(visibleRight>viewW){visibleRight=viewW}else if(visibleRight<0){visibleRight=0}var visibleTop=margin-layout.scrollTop();var visibleBottom=visibleTop+canvasH;if(visibleTop<0){visibleTop=0}else if(visibleTop>viewH){visibleTop=viewH}if(visibleBottom>viewH){visibleBottom=viewH}else if(visibleBottom<0){visibleBottom=0}var visibleW=visibleRight-visibleLeft;var visibleH=visibleBottom-visibleTop;if(visibleW==0||visibleH==0){navigator.hide()}else{var navLeft=layout.scrollLeft()-margin;if(navLeft<0){navLeft=0}navLeft=navLeft*(navW/canvasW);var navTop=layout.scrollTop()-margin;if(navTop<0){navTop=0}navTop=navTop*(navH/canvasH);var navViewW=visibleW*(navW/canvasW);var navViewH=visibleH*(navH/canvasH);navigator.css({left:navLeft-1,top:navTop-1,width:navViewW,height:navViewH}).show()}}};(function($){$.fn.button=function(options){if(typeof options=="string"){if(options=="disable"){$(this).addClass("disabled");$(this).find("input").attr("disabled",true)}else if(options=="enable"){$(this).removeClass("disabled");$(this).find("input").attr("disabled",false)}else if(options=="isDisabled"){return $(this).hasClass("disabled")}else if(options=="isSelected"){return $(this).hasClass("selected")}else if(options=="unselect"){$(this).removeClass("selected")}else if(options=="select"){$(this).addClass("selected")}else if(options=="setText"){$(this).children(".text_content").html(arguments[1])}else if(options=="setColor"){$(this).children(".btn_color").css("background-color","rgb("+arguments[1]+")")}else if(options=="getColor"){var color=$(this).children(".btn_color").css("background-color").replace(/\s/g,"");return color.substring(4,color.length-1)}return $(this)}var target=$(this);target.unbind("click");target.unbind("mousedown")if(options.onClick){target.bind("click",function(){if(target.button("isDisabled")){return}options.onClick()})}if(options.onMousedown){target.bind("mousedown",function(e){if(target.button("isDisabled")){return}options.onMousedown();e.stopPropagation()})}};var currentMenu=null;$.fn.dropdown=function(options){var menu=$(this);menu.find(".ico_selected").remove();if(typeof options=="string"){if(options=="close"){menu.hide();currentMenu.target.removeClass("selected");$(document).unbind("mousedown.ui_dropdown");currentMenu=null}else if(options=="select"){arguments[1].prepend("
          ")}return}if(currentMenu!=null){currentMenu.menu.dropdown("close")}var menu=$(this);var tar=options.target;currentMenu={target:tar,menu:menu};var offset=tar.offset();tar.addClass("selected");menu.show();var left;if(options.position=="center"){left=offset.left+tar.outerWidth()/2-menu.outerWidth()/2}else if(options.position=="right"){left=offset.left+tar.outerWidth()-menu.outerWidth()}else{left=offset.left}var top=offset.top+tar.outerHeight();if(top+menu.outerHeight()>$(window).height()){top=$(window).height()-menu.outerHeight()}menu.css({top:top,left:left});if(typeof options.zindex!="undefined"){menu.css("z-index",options.zindex)}menu.unbind("mousedown").bind("mousedown",function(e){e.stopPropagation()});if(typeof options.bind=="undefined"||options.bind==true){menu.find("li:not(.devider,.menu_text)").unbind().bind("click",function(){var item=$(this);if(!item.menuitem("isDisabled")&&item.children(".extend_menu").length==0){if(options.onSelect){options.onSelect(item)}menu.dropdown("close")}})}$(document).bind("mousedown.ui_dropdown",function(){menu.dropdown("close")})};$.colorpicker=function(options){var picker=$("#color_picker");picker.find(".selected").removeClass("selected");if(!picker.attr("init")){picker.find("div").each(function(){var color=$(this).css("background-color");color=color.replace(/\s/g,"");color=color.substring(4,color.length-1);$(this).attr("col",color)});picker.attr("init",true)}var opt=$.extend({},options,{bind:false});picker.dropdown(opt);picker.children(".color_items").children("div").unbind().bind("click",function(){if(options.onSelect){var color=$(this).css("background-color");color=color.replace(/\s/g,"");color=color.substring(4,color.length-1);options.onSelect(color)}$("#color_picker").dropdown("close")});if(options.color){picker.find("div[col='"+options.color+"']").addClass("selected")}$("#color_picker").children(".color_extend").remove();if(options.extend){$("#color_picker").append("
          "+options.extend+"
          ")}};$.fn.colorButton=function(opt){var tar=$(this);if(typeof opt=="string"){if(opt=="setColor"){tar.children(".picker_btn_holder").css("background-color","rgb("+arguments[1]+")")}return}tar.html("
          ");tar.bind("mousedown",function(e){if(tar.button("isDisabled")){return}e.stopPropagation();var options=$.extend({},opt);options.target=tar;options.onSelect=function(color){tar.colorButton("setColor",color);if(opt.onSelect){opt.onSelect(color)}};var color=$(this).children(".picker_btn_holder").css("background-color");color=color.replace(/\s/g,"");color=color.substring(4,color.length-1);options.color=color;$.colorpicker(options)})};$.fn.spinner=function(opt){var spinner=$(this);if(typeof opt=="string"){if(opt=="getValue"){var result=spinner.find("input").val();result=parseFloat(result);return result}else if(opt=="setValue"){spinner.find("input").val(arguments[1]);spinner.attr("old",arguments[1])}return}spinner.html("
          ");var defaults={min:0,max:Number.MAX_VALUE,step:1,unit:""};opt=$.extend(defaults,opt);var inputBox=spinner.children(".spinner_input");var input=inputBox.find("input");spinner.spinner("setValue",opt.min+opt.unit);spinner.find(".spinner_up").bind("click",function(){if(spinner.button("isDisabled")){return}var now=spinner.spinner("getValue");var newVal=now+opt.step;setSpinnerValue(spinner,newVal,opt)});spinner.find(".spinner_down").bind("click",function(){if(spinner.button("isDisabled")){return}var now=spinner.spinner("getValue");var newVal=now-opt.step;setSpinnerValue(spinner,newVal,opt)});input.bind("keydown",function(e){if(e.keyCode==13){var newVal=parseInt($(this).val());if(isNaN(newVal)){newVal=opt.min}setSpinnerValue(spinner,newVal,opt)}}).bind("focus",function(e){$(this).select();$(this).bind("mouseup",function(e){e.preventDefault();$(this).unbind("mouseup")});var box=$(this).parent().parent();if(!box.hasClass("active")){box.addClass("active inset")}}).bind("blur",function(e){var box=$(this).parent().parent();if(box.hasClass("inset")){box.removeClass("active inset")}})};function setSpinnerValue(spinner,value,opt){if(value>opt.max){value=opt.max}if(value0}else if(options=="unselect"){return target.children(".ico_selected").remove()}else if(options=="select"){return target.prepend("
          ")}}};$.fn.dlg=function(options){var dlg=$(this);if(typeof options=="string"){if(options=="close"){dlg.children(".dlg_close").trigger("click")}return}var defaults={closable:true};options=$.extend(defaults,options);var close=dlg.children(".dlg_close");if(close.length==0){close=$("
          ").appendTo(dlg)}if(options.closable==false){close.hide()}else{close.show()}$(".dlg_mask").remove();$("body").append("
          ")close.unbind().bind("click",function(){dlg.hide();$(".dlg_mask").remove();if(options&&options.onClose){options.onClose()}$(document).unbind("keydown.closedlg");dlg.find("input,textarea,select").unbind("keydown.closedlg")});dlg.css({left:($(window).width()-dlg.outerWidth())/2,top:($(window).height()-dlg.outerHeight())/2});dlg.show();if(options.closable){dlg.find("input,textarea,select").unbind("keydown.closedlg").bind("keydown.closedlg",function(e){if(e.keyCode==27){dlg.children(".dlg_close").trigger("click")}});$(document).unbind("keydown.closedlg").bind("keydown.closedlg",function(e){if(e.keyCode==27){dlg.children(".dlg_close").trigger("click")}})}dlg.children(".dialog_header").unbind("mousedown.drag_dlg").bind("mousedown.drag_dlg",function(e){var target=$(this).parent();var downX=e.pageX;var downY=e.pageY;var downLeft=target.offset().left;var downTop=target.offset().top;$(document).bind("mousemove.drag_dlg",function(e){var left=e.pageX-downX+downLeft;var top=e.pageY-downY+downTop;target.offset({left:left,top:top})});$(document).bind("mouseup.drag_dlg",function(e){$(document).unbind("mousemove.drag_dlg");$(document).unbind("mouseup.drag_dlg")})})}})(jQuery); \ No newline at end of file