/*globals svgEditor, svgCanvas, $*/ /*jslint vars: true, eqeq: true*/ /* * ext-helloworld.js * * Licensed under the MIT License * * Copyright(c) 2010 Alexis Deveria * */ var advancedClicked = false; svgEditor.addExtension("Advanced", function() {'use strict'; return { name: "Advanced", // The icon for 'advanced features' svgicons: svgEditor.curConfig.extPath + "advanced-icon.xml", // Multiple buttons can be added in this array buttons: [{ // Must match the icon ID in advanced-icon.xml id: "advanced", // This indicates that the button will be added independently to the buttons in the button // panel on the left side (it will not be unselected when one of the other buttons is selected) type: "context", panel: "tools_left", // Tooltip text title: "Show/Hide Advanced Features", // Events events: { 'click': function() { // Toggle the advanced button if (advancedClicked == true) { advancedClicked = false; // Hide advanced features advancedButton(advancedClicked); } else { advancedClicked = true; // Hide advanced features advancedButton(advancedClicked); } } } }], // This is triggered when the main mouse button is pressed down // on the editor canvas (not the tool panels) mouseDown: function() { advancedButton(advancedClicked); // The returned object must include "started" with // a value of true in order for mouseUp to be triggered return {started: true}; }, // This is triggered from anywhere, but "started" must have been set // to true (see above). Note that "opts" is an object with event info mouseUp: function(opts) { //advancedButton(advancedClicked); }, elementChanged: function(opts) { advancedButton(advancedClicked); }, callback: function(opts) { advancedClicked = false; advancedButton(advancedClicked); } }; }); // Function: advancedButton // Unless advanced button is selected, advanced features will be hidden this.advancedButton = function() { // 'Advanced feature' elements 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']; // Toggle the display attributes of the selected advanced elements for (var i = 0; i < elements.length; i++) { if (advancedClicked == false) { document.getElementById(elements[i]).style.display = 'none'; } else { document.getElementById(elements[i]).style.display = 'block'; } } // Remove strange extra 'tool_seps' when advanced features is not selected if (advancedClicked == false) { $("#selected_panel :first-child").find(".tool_sep").css("display", "none") } }