Skip to content

Commit

Permalink
Use a cookie to remember theme, tweak mode label positioning
Browse files Browse the repository at this point in the history
nathancox committed Jun 16, 2017
1 parent 1121add commit 343f58f
Showing 2 changed files with 19 additions and 7 deletions.
4 changes: 3 additions & 1 deletion css/CodeEditorField.css
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@

.codeeditor-button-bar {
padding-top:5px;
width: 512px;
/*width: 512px;*/
}

.codeeditor .ss-ui-button {
@@ -26,6 +26,8 @@
text-transform: uppercase;
color: #777777;
font-style: italic;

padding:4px 0;
}
.codeeditor .ss-ui-button.active {
background: linear-gradient(#338dc1, #287099);) repeat scroll 0 0 transparent;
22 changes: 16 additions & 6 deletions javascript/CodeEditorField.js
Original file line number Diff line number Diff line change
@@ -37,10 +37,15 @@
editor.getSession().setMode('ace/mode/' + this.data('mode'));

// load a theme if one is set
if (this.data('theme')) {
editor.setTheme('ace/theme/' + this.data('theme'));
}



if ($.cookie('codeeditorfield-theme')) {
editor.setTheme('ace/theme/' + $.cookie('codeeditorfield-theme'));
} else if (this.data('theme')) {
editor.setTheme('ace/theme/' + this.data('theme'));
}


var lineHeight = (editor.renderer.lineHeight > 1 ? editor.renderer.lineHeight : 16)

$div.css('min-height', lineHeight * textarea.attr('rows') + 35 + 'px');
@@ -95,11 +100,16 @@
onclick: function() {
var editor = this.getEditor();
var data = this.closest('.middleColumn').find('textarea').first();
var theme;
if (editor.getTheme() === ('ace/theme/' + data.data('dark'))) {
editor.setTheme('ace/theme/' + data.data('light'));
theme = data.data('light');
} else {
editor.setTheme('ace/theme/' + data.data('dark'));
theme = data.data('dark');
}
editor.setTheme('ace/theme/' + theme);
$.cookie('codeeditorfield-theme', theme);


return false;
}
});

0 comments on commit 343f58f

Please sign in to comment.