forked from MiguelCastillo/Brackets-Themes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeme.js
50 lines (38 loc) · 1.29 KB
/
theme.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
/*
* Brackets Themes Copyright (c) 2014 Miguel Castillo.
*
* Licensed under MIT
*/
/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */
/*global define, $, brackets, window, CodeMirror */
define(function (require, exports, module) {
"use strict";
/**
* Theme object to encasulate all the logic in one pretty bundle.
* The theme will self register when it is created.
*
* * Required settings are fileName and path
*
* @constructor
*/
function Theme(options) {
var _self = this;
$.extend(_self, options);
// Create a display and a theme name from the file name
_self.displayName = toDisplayName(_self.fileName);
_self.name = _self.fileName.substring(0, _self.fileName.lastIndexOf('.'));
}
/**
* Takes all dashes and converts them to white spaces...
* Then takes all first letters and capitalizes them.
*/
function toDisplayName (name) {
name = name.substring(0, name.lastIndexOf('.')).replace(/-/g, ' ');
var parts = name.split(" ");
$.each(parts.slice(0), function (index, part) {
parts[index] = part[0].toUpperCase() + part.substring(1);
});
return parts.join(" ");
}
return Theme;
});