forked from StarboyCZ/hide-status-bar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
64 lines (55 loc) · 1.63 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
define( function( require, exports, module )
{
"use strict";
// Modules
var app_init = brackets.getModule( "utils/AppInit" );
var cm_manager = brackets.getModule( "command/CommandManager" );
var e_manager = brackets.getModule( "editor/EditorManager" );
var menus = brackets.getModule( "command/Menus" );
var prefs_manager = brackets.getModule( "preferences/PreferencesManager" );
var statusbar = brackets.getModule( "widgets/StatusBar" );
// Action
app_init.appReady( function()
{
// Settings
var cm_id = "starboy.hideStatusBar.toggle";
var prefs_id = "starboy.hideStatusBar";
var prefs_def = { show: false };
// Declaration
var prefs, cm;
// Action
function e_action()
{
if( cm.getChecked()) statusbar.show();
else statusbar.hide();
}
// Event handlers
function cm_handler()
{
if( cm.getChecked()) cm.setChecked( false );
else cm.setChecked( true );
}
function state_handler()
{
prefs.set( "show", Boolean( cm.getChecked()));
e_action();
}
function e_handler()
{
e_action();
}
// Preferences
prefs = prefs_manager.getExtensionPrefs( prefs_id );
prefs.definePreference( "show", "boolean", prefs_def[ "show" ]);
// Command
cm = cm_manager.get( cm_id );
if ( cm ) cm._commandFn = cm_handler;
else cm = cm_manager.register( "Status bar", cm_id, cm_handler );
$( cm ).on( "checkedStateChange", state_handler );
cm.setChecked( prefs.get( "show" ));
// Menu
menus.getMenu( "view-menu" ).addMenuItem( cm_id );
// Sync
$( e_manager ).on( "activeEditorChange", e_handler );
});
});