allow for passing file to Ox.SyntaxHighlighter

This commit is contained in:
rolux 2012-06-23 20:24:06 +02:00
parent 6fcac07ee9
commit f473100875

View file

@ -4,6 +4,7 @@
Ox.SyntaxHighlighter <f> Syntax Highlighter
([options[, self]]) -> <o:Ox.Element> Syntax Highlighter
options <o> Options
file <s|''> JavaScript file (alternative to `source` option)
lineLength <n|0> If larger than zero, show edge of page
offset <n|1> 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,