mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-25 20:41:20 -05:00
dynamic loading works. #syntax #highlighting
This commit is contained in:
parent
1342992636
commit
e503c4af89
@ -4,15 +4,12 @@ CM.enabled = false;
|
||||
|
||||
CM.init = function() {
|
||||
CM.modes = $.parseJSON($('#codemirror_modes').text());
|
||||
$enable_codemirror = $('#enable_codemirror');
|
||||
|
||||
$enable_codemirror.click(function() {
|
||||
|
||||
//todo: no rebind
|
||||
$('#enable_codemirror').click(function() {
|
||||
$('#lang').change(function() {
|
||||
CM.set_language();
|
||||
});
|
||||
CM.toggle();
|
||||
CM.set_language();
|
||||
return false;
|
||||
});
|
||||
};
|
||||
@ -22,6 +19,7 @@ CM.toggle = function() {
|
||||
CM.editor.toTextArea();
|
||||
CM.editor = undefined;
|
||||
$('#lang').unbind();
|
||||
$('#enable_codemirror').text('Enable syntax highlighting');
|
||||
CM.enabled = false;
|
||||
} else {
|
||||
if (typeof CM.editor == 'undefined') {
|
||||
@ -30,23 +28,26 @@ CM.toggle = function() {
|
||||
lineWrapping: true,
|
||||
});
|
||||
}
|
||||
$('#enable_codemirror').text('Disable syntax highlighting');
|
||||
CM.enabled = true;
|
||||
}
|
||||
};
|
||||
|
||||
CM.set_language = function() {
|
||||
var lang = $('#lang').val();
|
||||
mode = CM.modes[lang];
|
||||
if (CM.enabled) {
|
||||
var lang = $('#lang').val();
|
||||
mode = CM.modes[lang];
|
||||
|
||||
$.get(base_url + 'main/get_cm_js/' + lang,
|
||||
function(data) {
|
||||
if (data != '') {
|
||||
CM.set_syntax(mode);
|
||||
} else {
|
||||
CM.set_syntax(null);
|
||||
}
|
||||
},
|
||||
'script');
|
||||
$.get(base_url + 'main/get_cm_js/' + lang,
|
||||
function(data) {
|
||||
if (data != '') {
|
||||
CM.set_syntax(mode);
|
||||
} else {
|
||||
CM.set_syntax(null);
|
||||
}
|
||||
},
|
||||
'script');
|
||||
}
|
||||
};
|
||||
|
||||
CM.set_syntax = function(mode) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user