summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2012-10-29 00:01:40 +0100
committerFlorian Pritz <bluewind@xinu.at>2012-10-29 00:01:40 +0100
commite36c3ab68634ef76ea06a6fed5b2cb0d5cbd97ed (patch)
tree5d2bedefeaa992d4bde1dd1d5d338411616503e5
parentb4e861155a122dd4871b6064c026efcefcc0f720 (diff)
Add button to wrap long lines in code view
Since wrapping would break the line numbers we hide them. Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--application/views/file/html_header.php1
-rw-r--r--data/js/script.js12
2 files changed, 13 insertions, 0 deletions
diff --git a/application/views/file/html_header.php b/application/views/file/html_header.php
index dc9bb05ad..e14bad6f5 100644
--- a/application/views/file/html_header.php
+++ b/application/views/file/html_header.php
@@ -74,6 +74,7 @@ include(FCPATH."application/views/header.php"); ?>
</li>
</ul>
<div class="btn-group pull-right" style="margin-top: 7px; margin-right:-10px;">
+ <a id="linewrap" class="btn btn-small" rel="tooltip" title="Wrap long lines">Linewrap</a>
<a href="<?php echo site_url($id."/plain") ?>" class="btn btn-small" rel="tooltip" title="View as plain text">Plain</a>
<a href="<?php echo site_url($id) ?>" class="btn btn-small" rel="tooltip" title="View as raw file (org. mime type)">Raw</a>
<?php if ($current_highlight === 'rmd') { ?>
diff --git a/data/js/script.js b/data/js/script.js
index 744722145..5faad3899 100644
--- a/data/js/script.js
+++ b/data/js/script.js
@@ -59,6 +59,18 @@ function fixedEncodeURIComponent (str) {
return this;
});
+ window.lines_wrapped = false;
+ $('#linewrap').click(function() {
+ if (window.lines_wrapped == true) {
+ $(".content .numbers").show();
+ $(".content .code > .highlight > pre").css("white-space", "pre");
+ } else {
+ $(".content .numbers").hide();
+ $(".content .code > .highlight > pre").css("white-space", "pre-wrap");
+ }
+ window.lines_wrapped = !window.lines_wrapped;
+ });
+
// check file size before uploading if browser support html5
if (window.File && window.FileList) {
function checkFileUpload(evt) {