modes & exec

This commit is contained in:
Claude 2012-04-23 19:08:44 +02:00
parent 771a736c58
commit 1415e54f01
4 changed files with 17 additions and 16 deletions

View File

@ -4,6 +4,11 @@
</div> </div>
</div> </div>
<?php <?php
//codemirror modes
echo '<div style="display: none;" id="codemirror_modes">' . json_encode($codemirror_modes) . '</div>';
//stats
$this->load->view('defaults/stats'); $this->load->view('defaults/stats');
//Javascript //Javascript
@ -12,6 +17,7 @@ $this->carabiner->js('jquery.timers.js');
$this->carabiner->js('jquery.clipboard.js'); $this->carabiner->js('jquery.clipboard.js');
$this->carabiner->js('stikked.js'); $this->carabiner->js('stikked.js');
$this->carabiner->js('codemirror/codemirror.js'); $this->carabiner->js('codemirror/codemirror.js');
$this->carabiner->js('codemirror_exec.js');
$this->carabiner->display('js'); $this->carabiner->display('js');

View File

@ -45,9 +45,7 @@
<div class="item"> <div class="item">
<label for="paste">Your paste <label for="paste">Your paste
<span class="instruction">Paste your paste here</span> <span class="instruction">Paste your paste here</span>
<?php if(isset($codemirror_languages[$lang_set]) && gettype($codemirror_languages[$lang_set]) == 'array'){ ?> <span class="instruction"><a href="#" id="enable_codemirror">Enable syntax highlighting</a></span>
<span class="instruction"><a href="#" id="enable_codemirror">Enable syntax highlighting</a></span>
<?php } ?>
</label> </label>
<textarea id="code" name="code" cols="40" rows="20" tabindex="4"><?php if(isset($paste_set)){ echo $paste_set; }?></textarea> <textarea id="code" name="code" cols="40" rows="20" tabindex="4"><?php if(isset($paste_set)){ echo $paste_set; }?></textarea>

View File

@ -13,19 +13,9 @@ $this->carabiner->js('jquery.timers.js');
$this->carabiner->js('jquery.clipboard.js'); $this->carabiner->js('jquery.clipboard.js');
$this->carabiner->js('stikked.js'); $this->carabiner->js('stikked.js');
$this->carabiner->js('codemirror/codemirror.js'); $this->carabiner->js('codemirror/codemirror.js');
$this->carabiner->js('codemirror_exec.js');
$this->carabiner->display('js'); $this->carabiner->display('js');
if(isset($codemirror_languages[$lang_set]) && gettype($codemirror_languages[$lang_set]) == 'array')
{
$codemirror_specific = array(
'js' => $codemirror_languages[$lang_set]['js'],
);
$codemirror_specific['js'][] = array('codemirror_exec.js');
$this->carabiner->group('codemirror', $codemirror_specific);
$this->carabiner->display('codemirror');
}
?> ?>
<script> <script>
</script> </script>

View File

@ -1,5 +1,7 @@
var CM = window.CM || {} var CM = window.CM || {}
CM.enabled = false;
CM.init = function() { CM.init = function() {
CM.modes = $.parseJSON($('#codemirror_modes').text()); CM.modes = $.parseJSON($('#codemirror_modes').text());
var lang = $('#lang').val(); var lang = $('#lang').val();
@ -31,11 +33,16 @@ CM.set_syntax = function(mode) {
$(document).ready(function() { $(document).ready(function() {
$enable_codemirror = $('#enable_codemirror'); $enable_codemirror = $('#enable_codemirror');
$enable_codemirror.click(function() { $enable_codemirror.click(function() {
CM.init();
$enable_codemirror.remove();
$('#lang').change(function() { $('#lang').change(function() {
CM.init(); CM.init();
}); });
if (CM.enabled) {
CM.editor.toTextArea()
CM.enabled = false;
} else {
CM.init();
CM.enabled = true;
}
return false; return false;
}); });
}); });