Skip to content

Commit

Permalink
ability to change tab's font, fix #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Bardanov committed Aug 28, 2014
1 parent b333dba commit 5a7a4de
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 6 deletions.
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ define(function (require, exports, module) {
require('./services/preferences').init();
require('./services/storage').init();
require('./services/tabSize');
require('./services/fonts').init();

require('./services/onlineTracking').init();

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "Documents Toolbar",
"description": "Adds toolbar with tabs of open documents on the top of the editor. Now with drag and drop!",
"homepage": "https://github.com/dnbard/brackets-documents-toolbar",
"version": "0.3.1",
"version": "0.4.0",
"author": "Alex Bardanov <dnbard@gmail.com>",
"license": "MIT",
"engines": {
Expand Down
35 changes: 35 additions & 0 deletions services/fonts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var PreferencesManager = require('preferences/PreferencesManager');

define(function(require, exports, module){
var prefs = PreferencesManager.getExtensionPrefs("fonts"),
isChange = false;

// monitor brackets.json file changes
prefs.on("change", "fontSize", applyFontChanges);

// monitor brackets.json file changes
prefs.on("change", "fontFamily", applyFontChanges);

function applyFontChanges(){
if (!isChange){
return;
}
$('.brFont').css('font-size', prefs.get("fontSize"))
.css('font-family', prefs.get("fontFamily"));
}

exports.init = function(){
console.log(prefs.get("fontSize"));
console.log(prefs.get("fontFamily"));
}

exports.change = function(value){
isChange = value;
if (value){
applyFontChanges();
} else {
$('.brFont').css('font-size', 'inherit')
.css('font-family', 'inherit');
}
}
});
3 changes: 2 additions & 1 deletion services/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ define(function(require, exports){
icons: true,
tooltip: false,
close_left: false,
workingFiles: true
workingFiles: true,
brackets_font: true
};

exports.init = function(){
Expand Down
6 changes: 5 additions & 1 deletion styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
white-space: nowrap;
}

.ext-documents .document-holder{
position: absolute;
}

.ext-documents .document{
padding-left: 12px;
padding-right: 8px;
Expand Down Expand Up @@ -72,9 +76,9 @@
padding-right: 4px;
display: inline-block;
overflow-x: hidden;
overflow-y: hidden;
text-align: center;
max-width: 12em;
/*transition: all 0.25s;*/
}

.ext-documents .document:before{
Expand Down
4 changes: 2 additions & 2 deletions templates/holder.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<i class="fa fa-cog button-icon" data-bind="click: onShowOptions" title="Show extension's options"></i>
<i class="fa fa-times button-icon" data-bind="click: onDocumentCloseAll" title="Close all open documents"></i>
</span>
<span class="document-holder" data-bind="foreach: documents">
<span class="document-holder brFont" data-bind="foreach: documents">
<span class="document" data-bind="style:{background: $parent.getDocumentBackground($data)}, css:{selected: $data._path === $parent.selectedPath(), changed: $parent.isChanged($data)}, click: $parent.onDocumentClick, event:{mouseover: $parent.onDocumentMouseIn, mouseleave: $parent.onDocumentMouseLeave, contextmenu: $parent.onDocumentContextMenu, mousedown: $parent.onDocumentMouseDown}, attr:{title: $data._path}, drag: true">
<span class="document-close" data-bind="click: $parent.onDocumentClose, style:{color: $parent.getDocumentNameColor($data)}, visible: $parent.isCloseOnLeft()">
<i class="fa fa-times-circle"></i>
</span>
<span class="document-icon" data-bind="css: $parent.getDocumentIcon($data), style:{color: $parent.getDocumentIconColor($data)}, visible: $parent.iconsEnabled"></span>
<span class="document-name" data-bind="html: $parent.getDocumentName($data), style:{color: $parent.getDocumentNameColor($data)}"></span>
<span class="document-name" data-bind="text: $parent.getDocumentName($data), style:{color: $parent.getDocumentNameColor($data)}"></span>
<span class="document-close" data-bind="click: $parent.onDocumentClose, style:{color: $parent.getDocumentNameColor($data)}, visible: !$parent.isCloseOnLeft()">
<i class="fa fa-times-circle"></i>
</span>
Expand Down
4 changes: 4 additions & 0 deletions templates/modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ <h1 class="dialog-title">Documents toolbar settings</h1>
<input type="checkbox" data-bind="checked: showIcons" />
<span>Show Icons</span>
</div>
<div>
<input type="checkbox" data-bind="checked: useBracketsFont" />
<span>Use Brackets font settings</span>
</div>
</div>
<div data-page="RULES" data-bind="visible: isCurrentPageSelected($data, $element)">
<div class="rule-set" data-bind="foreach: rules">
Expand Down
5 changes: 5 additions & 0 deletions viewmodels/documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ define(function(require, exports, module){
self.iconsEnabled(value);
});

this.fontEnabled = ko.observable(prefs.get('brackets_font'));
prefs.notifier('brackets_font', function(value){
self.fontEnabled(value);
});

this.onDocumentClick = function(model, event){
DocumentManager.getDocumentForPath(model._path)
.done(function(doc){
Expand Down
10 changes: 9 additions & 1 deletion viewmodels/generalOptions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
define(function(require, exports, module){
var ko = require('../vendor/knockout'),
prefs = require('../services/preferences'),
ExtensionUtils = brackets.getModule('utils/ExtensionUtils');
ExtensionUtils = brackets.getModule('utils/ExtensionUtils'),
fonts = require('../services/fonts');

function showWorkingFiles(value){
if (value){
Expand All @@ -23,8 +24,15 @@ define(function(require, exports, module){
prefs.set('icons', value);
});

this.useBracketsFont = ko.observable();
this.useBracketsFont.subscribe(function(value){
fonts.change(value);
prefs.set('brackets_font', value);
});

this.showWorkingFiles(prefs.get('workingFiles'));
this.showIcons(prefs.get('icons'));
this.useBracketsFont(prefs.get('brackets_font'));
}

module.exports = GeneralOptions;
Expand Down

0 comments on commit 5a7a4de

Please sign in to comment.