Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add ability to change font size, and settings structure added

  • Loading branch information...
commit 7405355068379af79c0ae7dcaecfcf18dfa58348 1 parent 03f2eac
Justin Cooper authored
View
4 controllers/editor.js
@@ -21,10 +21,6 @@ exports.index = function(req, res) {
};
-exports.settings = function(req, res) {
-
-};
-
exports.create_repository = function(req, res) {
var repository_url = sanitize(req.body.repository_url).xss().trim();
View
1  helpers/editor_setup.js
@@ -26,6 +26,7 @@ var exec = require('child_process').exec,
console.log(project_repository);
client.hgetall('editor:settings', function(err, settings) {
+ console.log("getting settings", settings);
socket.emit("self-check-settings", settings);
});
View
36 public/javascripts/occ_editor.js
@@ -23,6 +23,7 @@
'</p>',
"editor_bar_settings_manager": '<p class="editor-bar-actions">' +
'Edit your settings' +
+ '<span class="saved-setting" style="display: none;"></span>' +
'<a href="" class="close-settings-manager"><i class="icon-remove"></i> Close</a>' +
'</p>',
"editor_bar_interpreted_file": '<p class="editor-bar-actions">' +
@@ -120,8 +121,8 @@
socket.on("self-check-message", function(message) {
editor_startup(message);
});
- socket.on("self-check-settings", function(settings) {
- console.log(settings);
+ socket.on("self-check-settings", function(data) {
+ settings = data;
editor_startup("Editor settings received");
});
socket.on("self-check-complete", function() {
@@ -253,7 +254,7 @@
session.setUseSoftTabs(false);
if (typeof settings !== 'undefined' && settings.font_size) {
- editor.setFontSize(settings.font_size);
+ editor.setFontSize(settings.font_size + "px");
}
if (file.path) {
@@ -490,7 +491,7 @@
tty.off('tab-ready');
if (typeof settings !== 'undefined' && settings.font_size) {
- $('.terminal').css('font-size', settings.font_size);
+ $('.terminal').css('font-size', settings.font_size + "px");
}
if (command) {
@@ -1093,9 +1094,20 @@
}
function view_settings() {
+ function set_settings(value) {
+ if (typeof settings === 'undefined') {
+ settings = {};
+ }
+ settings = $.extend({}, settings, value);
+
+ socket.emit("set-settings", value);
+ $('.saved-setting').html('<i class="icon-ok"></i> Saved').delay(100).fadeIn('slow').fadeOut();
+ }
+
function close_settings_manager(event) {
event.preventDefault();
$(document).off('click touchstart', '.close-settings-manager');
+ $(document).off('click touchstart', '.font-size-value');
$('#settings-manager').hide();
$('#editor').show();
@@ -1107,10 +1119,24 @@
occEditor.populate_editor_bar();
}
}
+
+ function set_font_size(event) {
+ $('.font-size-value').removeClass('selected');
+ $(this).addClass('selected');
+ set_settings({"font_size": $(this).text()});
+ }
+
+ if (typeof settings !== 'undefined' && settings.font_size) {
+ $('.font-size-value.' + settings.font_size + 'px').addClass('selected');
+ } else {
+ $('.font-size-value.12px').addClass('selected');
+ }
+
$('#editor').hide();
- //$('#settings-manager').html("");
$('#settings-manager').show();
$('#editor-bar').html(templates.editor_bar_settings_manager);
+
+ $(document).on('click touchstart', '.font-size-value', set_font_size);
$(document).on('click touchstart', '.close-settings-manager', close_settings_manager);
}
View
27 public/stylesheets/app.css
@@ -461,6 +461,33 @@ a.navigator-settings i.settings-enabled {
float: right;
}
+#editor-bar .saved-setting {
+ padding-left: 10px;
+}
+
+#settings-manager .settings-element {
+ margin-top: 9px;
+}
+
+#settings-manager span {
+ border: 1px solid #B4B4B4;
+ background-color: #EDEEEE;
+ color: #2F3133;
+ font-size: 12px;
+ font-weight: bold;
+ padding: 10px;
+ margin: 0 1px 0 0;
+}
+
+.settings-element .font-size-value {
+ cursor: pointer;
+}
+
+#settings-manager span.selected {
+ border: 1px solid #B4B4B4;
+ background-color: #B4B4B4;
+}
+
#editor-output-wrapper {
position: absolute;
bottom: 0;
View
7 server.js
@@ -129,7 +129,6 @@ app.use(app.router);
app.get('/', ensureAuthenticated, site.index);
app.get('/editor', ensureAuthenticated, editor.index);
-app.post('/editor/settings', ensureAuthenticated, editor.settings);
app.get('/editor/image', ensureAuthenticated, editor.image);
app.post('/editor/upload', ensureAuthenticated, editor.upload_file);
@@ -365,6 +364,12 @@ function socket_listeners() {
socket.on('schedule-toggle-job', function(key) {
scheduler.toggle_job(key, socket, socket.handshake.session);
});
+
+ socket.on('set-settings', function(value) {
+ client.hmset("editor:settings", value, function(err) {
+ console.log(err);
+ });
+ });
});
}
View
12 views/editor/index.jade
@@ -21,11 +21,13 @@ block content
#schedule-manager
#settings-manager
form(method="post", action="/editor/settings")
- label Font Size:
- select(name="settings[font]")
- option(value="12px") 12px
- option(value="14px") 14px
- option(value="16px") 16px
+ .settings-element
+ span Select Font Size (px):
+ span.font-size-value.10px 10
+ span.font-size-value.12px 12
+ span.font-size-value.14px 14
+ span.font-size-value.16px 16
+ span.font-size-value.20px 20
#editor
#editor-output-wrapper
#dragbar
Please sign in to comment.
Something went wrong with that request. Please try again.