allow for passing file to Ox.SyntaxHighlighter
This commit is contained in:
parent
6fcac07ee9
commit
f473100875
1 changed files with 10 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
||||||
Ox.SyntaxHighlighter <f> Syntax Highlighter
|
Ox.SyntaxHighlighter <f> Syntax Highlighter
|
||||||
([options[, self]]) -> <o:Ox.Element> Syntax Highlighter
|
([options[, self]]) -> <o:Ox.Element> Syntax Highlighter
|
||||||
options <o> Options
|
options <o> Options
|
||||||
|
file <s|''> JavaScript file (alternative to `source` option)
|
||||||
lineLength <n|0> If larger than zero, show edge of page
|
lineLength <n|0> If larger than zero, show edge of page
|
||||||
offset <n|1> First line number
|
offset <n|1> First line number
|
||||||
replace <[[]]|[]> Array of replacements
|
replace <[[]]|[]> Array of replacements
|
||||||
|
@ -24,6 +25,7 @@ Ox.SyntaxHighlighter = function(options, self) {
|
||||||
self = self || {};
|
self = self || {};
|
||||||
var that = Ox.Element({}, self)
|
var that = Ox.Element({}, self)
|
||||||
.defaults({
|
.defaults({
|
||||||
|
file: '',
|
||||||
lineLength: 0,
|
lineLength: 0,
|
||||||
offset: 1,
|
offset: 1,
|
||||||
replace: [],
|
replace: [],
|
||||||
|
@ -39,7 +41,14 @@ Ox.SyntaxHighlighter = function(options, self) {
|
||||||
.update(renderSource)
|
.update(renderSource)
|
||||||
.addClass('OxSyntaxHighlighter');
|
.addClass('OxSyntaxHighlighter');
|
||||||
|
|
||||||
renderSource();
|
if (self.options.file) {
|
||||||
|
Ox.get(self.options.file, function(source) {
|
||||||
|
self.options.source = source;
|
||||||
|
renderSource();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
renderSource();
|
||||||
|
}
|
||||||
|
|
||||||
function renderSource() {
|
function renderSource() {
|
||||||
var $lineNumbers, $line, $source, width,
|
var $lineNumbers, $line, $source, width,
|
||||||
|
|
Loading…
Reference in a new issue