-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcaseConverter.js
37 lines (26 loc) · 1.05 KB
/
caseConverter.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
/*global define, brackets */
define( function( require, exports, module ) {
"use strict";
var DocumentManager = brackets.getModule( 'document/DocumentManager' ),
EditorManager = brackets.getModule( 'editor/EditorManager' );
this.convert = function( uppercase ) {
var currentEditor = EditorManager.getCurrentFullEditor(),
selectedText = currentEditor.getSelectedText(),
selectedPos = currentEditor.getSelection(),
doc = DocumentManager.getCurrentDocument(),
start = selectedPos.start,
end = selectedPos.end,
txt = "";
if ( uppercase ) txt = selectedText.toUpperCase();
else txt = selectedText.toLowerCase();
doc.replaceRange( txt, start, end );
};
this.uppercase = function() {
this.convert( true );
}.bind( this );
this.lowercase = function() {
this.convert( false );
}.bind( this );
exports.uppercase = this.uppercase;
exports.lowercase = this.lowercase;
} );