Merge branch 'ztflow-sunhao-main#sunhao' of zentao/zentaopms (#46)
This commit is contained in:
@@ -36,7 +36,9 @@ class treemap extends wg
|
||||
'nodeTemplate?: string', // 节点元素模板。
|
||||
'onNodeClick?: function', // 节点元素模板。
|
||||
'afterDrawLines?: function', // 节点元素模板。
|
||||
'afterRender?: function' // 节点元素模板。
|
||||
'afterRender?: function', // 节点元素模板。
|
||||
'onContextMenu?: function', // 上下文菜单事件回调函数。
|
||||
'onReady?: function' // 组件就绪回调函数。
|
||||
);
|
||||
|
||||
protected function build(): array
|
||||
@@ -46,7 +48,7 @@ class treemap extends wg
|
||||
list($width, $height) = $this->prop(array('width', 'height'));
|
||||
$dataVarName = "_treemap_$this->gid";
|
||||
$treemapPath = $app->getWebRoot() . 'js/zui/treemap/index.html?options=' . $dataVarName;
|
||||
$options = $this->props->pick(array('hotkeyEnable', 'hotkeys', 'lang', 'langs', 'data', 'nodeTeamplate', 'hSpace', 'vSpace', 'canvasPadding', 'removingNodeTip', 'lineCurvature', 'subLineWidth', 'lineColor', 'lineOpacity', 'lineSaturation', 'lineLightness', 'nodeLineWidth', 'showToggleButton', 'readonly', 'minimap', 'toolbar', 'zoom', 'zoomMax', 'zoomMin', 'minimapHeight', 'onNodeClick', 'afterDrawLines', 'afterRender'));
|
||||
$options = $this->props->pick(array('hotkeyEnable', 'hotkeys', 'lang', 'langs', 'data', 'nodeTeamplate', 'hSpace', 'vSpace', 'canvasPadding', 'removingNodeTip', 'lineCurvature', 'subLineWidth', 'lineColor', 'lineOpacity', 'lineSaturation', 'lineLightness', 'nodeLineWidth', 'showToggleButton', 'readonly', 'minimap', 'toolbar', 'zoom', 'zoomMax', 'zoomMin', 'minimapHeight', 'onNodeClick', 'afterDrawLines', 'afterRender', 'onReady', 'onContextMenu'));
|
||||
return array
|
||||
(
|
||||
h::jsVar("window.$dataVarName", $options),
|
||||
|
||||
@@ -29,6 +29,7 @@ if(!options.manual) $('#mindmap').mindmap(options);
|
||||
parent.createMindmap = function(userOptions){return $('#mindmap').mindmap($.extend({}, options, userOptions)).data('zui.mindmap');};
|
||||
parent.getMindmap = function(){return $('#mindmap').data('zui.mindmap');};
|
||||
parent.mindmap$ = $;
|
||||
$('body').on('click', () => window.parent.$(window.frameElement).trigger('click'));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -25,6 +25,28 @@ window.parent.$(function()
|
||||
$('#treemap').treemap($.extend({}, window.parent[$.getSearchParam('options')]));
|
||||
const treemap = $('#treemap').data('zui.treemap');
|
||||
window.parent.getTreemap = function() {return treemap;};
|
||||
if(treemap.options.onReady) treemap.options.onReady(treemap, window);
|
||||
$('body').on('click', () => window.parent.$(window.frameElement).trigger('click'));
|
||||
if(treemap.options.onContextMenu)
|
||||
{
|
||||
treemap.$nodes.on('contextmenu', function(e)
|
||||
{
|
||||
const $node = $(e.target).closest('.treemap-node');
|
||||
const node = $node.data('node');
|
||||
const frameBounding = window.frameElement.getBoundingClientRect();
|
||||
const clientX = e.clientX + frameBounding.left;
|
||||
const clientY = e.clientY + frameBounding.top;
|
||||
let result = treemap.options.onContextMenu({node: node, clientX: clientX, clientY: clientY, treemap: treemap, event: e});
|
||||
if(!result) return;
|
||||
if(Array.isArray(result)) result = {items: result};
|
||||
window.parent.zui.ContextMenu.show($.extend(
|
||||
{
|
||||
element: {getBoundingClientRect: () => ({x: clientX, y: clientY, width: 0, height: 0, left: clientX, top: clientY})},
|
||||
}, result));
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user