From f4731008751bdc2633e1f8962ad28a4a9ce07db2 Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 23 Jun 2012 20:24:06 +0200 Subject: [PATCH] allow for passing file to Ox.SyntaxHighlighter --- source/Ox.UI/js/Code/SyntaxHighlighter.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/Ox.UI/js/Code/SyntaxHighlighter.js b/source/Ox.UI/js/Code/SyntaxHighlighter.js index 54131d31..4840b288 100644 --- a/source/Ox.UI/js/Code/SyntaxHighlighter.js +++ b/source/Ox.UI/js/Code/SyntaxHighlighter.js @@ -4,6 +4,7 @@ Ox.SyntaxHighlighter Syntax Highlighter ([options[, self]]) -> Syntax Highlighter options Options + file JavaScript file (alternative to `source` option) lineLength If larger than zero, show edge of page offset First line number replace <[[]]|[]> Array of replacements @@ -24,6 +25,7 @@ Ox.SyntaxHighlighter = function(options, self) { self = self || {}; var that = Ox.Element({}, self) .defaults({ + file: '', lineLength: 0, offset: 1, replace: [], @@ -39,7 +41,14 @@ Ox.SyntaxHighlighter = function(options, self) { .update(renderSource) .addClass('OxSyntaxHighlighter'); - renderSource(); + if (self.options.file) { + Ox.get(self.options.file, function(source) { + self.options.source = source; + renderSource(); + }); + } else { + renderSource(); + } function renderSource() { var $lineNumbers, $line, $source, width,