source: other-projects/nz-flag-design/trunk/svg-editor-ext/ext-advanced.js@ 29968

Last change on this file since 29968 was 29744, checked in by davidb, 9 years ago

Extra files for SVG-Editor that give us the customizations we want

  • Property svn:executable set to *
File size: 3.5 KB
Line 
1/*globals svgEditor, svgCanvas, $*/
2/*jslint vars: true, eqeq: true*/
3/*
4 * ext-helloworld.js
5 *
6 * Licensed under the MIT License
7 *
8 * Copyright(c) 2010 Alexis Deveria
9 *
10 */
11var advancedClicked = false;
12
13svgEditor.addExtension("Advanced", function() {'use strict';
14
15 return {
16 name: "Advanced",
17 // The icon for 'advanced features'
18 svgicons: svgEditor.curConfig.extPath + "advanced-icon.xml",
19
20 // Multiple buttons can be added in this array
21 buttons: [{
22 // Must match the icon ID in advanced-icon.xml
23 id: "advanced",
24
25 // This indicates that the button will be added independently to the buttons in the button
26 // panel on the left side (it will not be unselected when one of the other buttons is selected)
27 type: "context",
28 panel: "tools_left",
29
30 // Tooltip text
31 title: "Show/Hide Advanced Features",
32
33 // Events
34 events: {
35 'click': function() {
36 // Toggle the advanced button
37 if (advancedClicked == true)
38 {
39 advancedClicked = false;
40 // Hide advanced features
41 advancedButton(advancedClicked);
42 }
43 else
44 {
45 advancedClicked = true;
46 // Hide advanced features
47 advancedButton(advancedClicked);
48 }
49 }
50 }
51 }],
52 // This is triggered when the main mouse button is pressed down
53 // on the editor canvas (not the tool panels)
54 mouseDown: function() {
55 advancedButton(advancedClicked);
56
57 // The returned object must include "started" with
58 // a value of true in order for mouseUp to be triggered
59 return {started: true};
60 },
61
62 // This is triggered from anywhere, but "started" must have been set
63 // to true (see above). Note that "opts" is an object with event info
64 mouseUp: function(opts) {
65 //advancedButton(advancedClicked);
66 },
67
68 elementChanged: function(opts)
69 {
70 advancedButton(advancedClicked);
71 },
72
73 callback: function(opts) {
74 advancedClicked = false;
75 advancedButton(advancedClicked);
76 }
77 };
78});
79
80// Function: advancedButton
81// Unless advanced button is selected, advanced features will be hidden
82this.advancedButton = function() {
83
84 // 'Advanced feature' elements
85 var elements = ['sidepanels', 'editor_panel', 'tool_move_top', 'tool_move_bottom', 'tool_topath', 'tool_reorient', 'tool_make_link', 'idLabel', 'tool_angle', 'tool_blur', 'tool_position', 'xy_panel', 'rect_width_tool', 'rect_height_tool', 'cornerRadiusLabel'];
86
87 // Toggle the display attributes of the selected advanced elements
88 for (var i = 0; i < elements.length; i++) {
89 if (advancedClicked == false) {
90 document.getElementById(elements[i]).style.display = 'none';
91 }
92 else {
93 document.getElementById(elements[i]).style.display = 'block';
94 }
95 }
96
97 // Remove strange extra 'tool_seps' when advanced features is not selected
98 if (advancedClicked == false)
99 {
100 $("#selected_panel :first-child").find(".tool_sep").css("display", "none")
101 }
102}
Note: See TracBrowser for help on using the repository browser.