Permalink
Browse files

Add Toolbar Button, closes #211

  • Loading branch information...
1 parent 5d9213f commit d4180cbce8928853b063ad40c2670256dede0c39 @Hirse Hirse committed Jun 11, 2016
Showing with 19 additions and 1 deletion.
  1. +11 −1 main.js
  2. +3 −0 styles/icons/wand.svg
  3. +5 −0 styles/styles.css
View
@@ -1,4 +1,4 @@
-define(function (require) {
+define(function (require, exports, module) {
'use strict';
var PREFIX = 'bb.beautify';
@@ -35,6 +35,7 @@ define(function (require) {
var PreferencesManager = brackets.getModule('preferences/PreferencesManager');
var ProjectManager = brackets.getModule('project/ProjectManager');
var AppInit = brackets.getModule('utils/AppInit');
+ var ExtensionUtils = brackets.getModule('utils/ExtensionUtils');
var DefaultDialogs = brackets.getModule('widgets/DefaultDialogs');
var Dialogs = brackets.getModule('widgets/Dialogs');
/* beautify preserve:end */
@@ -53,6 +54,7 @@ define(function (require) {
var defaultOptions = JSON.parse(require('text!default.jsbeautifyrc'));
var options;
+ ExtensionUtils.loadStyleSheet(module, 'styles/styles.css');
var prefs = PreferencesManager.getExtensionPrefs(PREFIX);
function batchUpdate(formattedText, range) {
@@ -252,6 +254,14 @@ define(function (require) {
jsonLanguage.addFileExtension(OPTIONS_FILE_NAME);
jsonLanguage.addFileName(OPTIONS_FILE_NAME);
+ // Add Toolbar Button
+ $(document.createElement('a'))
+ .attr('id', 'beautify-icon')
+ .attr('href', '#')
+ .attr('title', Strings.BEAUTIFY)
+ .on('click', format)
+ .appendTo($('#main-toolbar .buttons'))
+
AppInit.appReady(function () {
DocumentManager.on('documentSaved.beautify', onSave);
DocumentManager.on('documentSaved.beautifyOptions', loadOptionsOnChange);
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24">
+ <path fill="#bbbbbb" transform="translate(3, 3) scale(0.5625, 0.5625)" d="M8 6l-4-4h-2v2l4 4zM10 0h2v4h-2zM18 10h4v2h-4zM20 4v-2h-2l-4 4 2 2zM0 10h4v2h-4zM10 18h2v4h-2zM2 18v2h2l4-4-2-2zM31.563 27.563l-19.879-19.879c-0.583-0.583-1.538-0.583-2.121 0l-1.879 1.879c-0.583 0.583-0.583 1.538 0 2.121l19.879 19.879c0.583 0.583 1.538 0.583 2.121 0l1.879-1.879c0.583-0.583 0.583-1.538 0-2.121zM15 17l-6-6 2-2 6 6-2 2z"></path>
+</svg>
View
@@ -0,0 +1,5 @@
+/* ==== Toolbar Icon ==== */
+
+#beautify-icon {
+ background-image: url(icons/wand.svg);
+}

0 comments on commit d4180cb

Please sign in to comment.