codemirror on demand

This commit is contained in:
Claude 2012-04-20 08:48:50 +02:00
parent 1a7660047f
commit 4cc15a9121
3 changed files with 14 additions and 2 deletions

View File

@ -254,7 +254,7 @@ class Pastes extends CI_Model
$this->db->select('title, name, created, pid, snipurl'); $this->db->select('title, name, created, pid, snipurl');
$this->db->where('replyto', $data['pid']); $this->db->where('replyto', $data['pid']);
$this->db->order_by('id', 'desc'); $this->db->order_by('id', 'desc');
$this->db->limit(10); $this->db->limit(100);
$query = $this->db->get('pastes'); $query = $this->db->get('pastes');
if ($query->num_rows() > 0) if ($query->num_rows() > 0)

View File

@ -45,6 +45,13 @@
<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($this->uri->segment(1) == 'view'
&& isset($codemirror_languages[$lang_set])
&& gettype($codemirror_languages[$lang_set]) == 'array'){
?><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

@ -9,5 +9,10 @@ CM.init = function() {
}; };
$(document).ready(function() { $(document).ready(function() {
CM.init(); $enable_codemirror = $('#enable_codemirror');
$enable_codemirror.click(function() {
CM.init();
$enable_codemirror.remove();
return false;
});
}); });