From 796cee60e14e7e38882ebd6952a4fd5599e07013 Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Fri, 19 Feb 2010 16:55:08 +0000 Subject: [PATCH] A little more work on the closepath extension (still doesn't show SVG icons yet) git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1412 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/extensions/closepath_icons.svg | 44 +++++++++++++++++++++++++++ editor/extensions/ext-closepath.js | 33 +++++++++++++++----- editor/svg-editor.html | 2 +- editor/svg-editor.js | 9 +++--- 4 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 editor/extensions/closepath_icons.svg diff --git a/editor/extensions/closepath_icons.svg b/editor/extensions/closepath_icons.svg new file mode 100644 index 00000000..f33f6be7 --- /dev/null +++ b/editor/extensions/closepath_icons.svg @@ -0,0 +1,44 @@ + + + + + + + + + + Layer 1 + + + + + + + + + + + + + + + + Layer 1 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/editor/extensions/ext-closepath.js b/editor/extensions/ext-closepath.js index 2f943d02..28afd61c 100644 --- a/editor/extensions/ext-closepath.js +++ b/editor/extensions/ext-closepath.js @@ -14,8 +14,11 @@ $(function() { var selElems, updateButton = function(path) { var seglist = path.pathSegList, - button = $('#closepath_panel > div.tool_button')[0]; - $(button).html(seglist.getItem(seglist.numberOfItems - 1).pathSegType==1 ? "open":"close"); + closed = seglist.getItem(seglist.numberOfItems - 1).pathSegType==1, + showbutton = closed ? '#tool_openpath' : '#tool_closepath', + hidebutton = closed ? '#tool_closepath' : '#tool_openpath'; + $(hidebutton).hide(); + $(showbutton).show(); }, showPanel = function(on) { $('#closepath_panel').toggle(on); @@ -43,12 +46,28 @@ $(function() { return { name: "ClosePath", - context_tools: [{ - type: "tool_button", + svgicons: "extensions/closepath-icons.svg", + buttons: [{ + id: "tool_openpath", + type: "context", panel: "closepath_panel", - title: "Open or Close path", - id: "close", - events: { mousedown: toggleClosed } + title: "Open path", + events: { + 'click': function() { + toggleClosed(); + } + } + }, + { + id: "tool_closepath", + type: "context", + panel: "closepath_panel", + title: "Close path", + events: { + 'click': function() { + toggleClosed(); + } + } }], callback: function() { $('#closepath_panel').hide(); diff --git a/editor/svg-editor.html b/editor/svg-editor.html index c3d8fb05..01b1b504 100644 --- a/editor/svg-editor.html +++ b/editor/svg-editor.html @@ -21,7 +21,7 @@ - +