/wp-js-syntax-highlighter/trunk/loader.js |
---|
1,2 → 1,2 |
//$Rev$ See <http://p.outlyer.net./wordpress/> |
if("undefined"==typeof(jQuery)){var s=document.createElement("SCRIPT");s.src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js";s.type="text/javascript";document.getElementsByTagName("HEAD")[0].appendChild(s)}var shLoader={init:function(a){if(a){for(var b in a){this[b]=a[b]}}$(document).ready(function(){shLoader.load()})},load:function(){if(!jQuery){return}var a=this.path+"/sh/styles";var b=this.path+"/sh/scripts";this.detectLanguages();if(0==this.loadURLs.length){return}$('<link rel="stylesheet" href="'+a+'/shCore.css" type="text/css">').appendTo($("head"));$('<link rel="stylesheet" href="'+a+"/shTheme"+this.theme+'.css" type="text/css">').appendTo($("head"));$.ajax({url:b+"/shCore.js",dataType:"script",async:false});$(this.loadURLs).each(function(d,f){$.ajax({url:f,dataType:"script",async:false,})});if("undefined"==typeof(SyntaxHighlighter)){return}for(var c in this.configObj){SyntaxHighlighter.config[c]=this.configObj[c]}for(var c in this.defaultsObj){SyntaxHighlighter.defaults[c]=this.defaultsObj[c]}SyntaxHighlighter.all()},setDefaults:function(a){this.defaultsObj=a},setConfig:function(a){this.configObj=a},detectLanguages:function(){var a=[];var b=/brush: (\w+)/i;$(".brush\\:").each(function(){var d=$(this).attr("class");var c=d.match(b)[1];shLoader.reqLoad(c)})},reqLoad:function(b){var a=null;switch(b){case"cpp":case"c":case"c++":a="Cpp";break;case"c#":case"c-sharp":case"csharp":a="CSharp";break;case"css":a="Css";break;case"delphi":case"pascal":a="Delphi";break;case"java":a="Java";break;case"js":case"jscript":case"javascript":a="JScript";break;case"php":a="Php";break;case"py":case"python":a="Python";break;case"rb":case"ruby":case"rails":case"ror":a="Ruby";break;case"sql":a="Sql";break;case"vb":case"vb.net":a="Vb";break;case"xml":case"html":case"xhtml":case"xslt":a="Xml";break;default:}if(a){if(!this.loaded[a]){this.loadURLs[this.loadURLs.length]=this.path+"/sh/scripts/shBrush"+a+".js";this.loaded[a]=true}}},getDefaults:function(){return this.defaultsObj},getConfig:function(){return this.configObj},theme:"Default",path:"/wp-content/plugins/js-syntax-highlighter",loaded:[],loadURLs:[],configObj:{},defaultsObj:{},}; |
if("undefined"==typeof(jQuery)){var s=document.createElement("SCRIPT");s.src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js";s.type="text/javascript";document.getElementsByTagName("HEAD")[0].appendChild(s)}var shLoader={init:function(a){if(a){for(var b in a){this[b]=a[b]}}$(document).ready(function(){shLoader.load()})},load:function(){if(!jQuery){return}var a=this.path+"/sh/styles";var b=this.path+"/sh/scripts";this.detectLanguages();if(0==this.loadURLs.length){return}$('<link rel="stylesheet" href="'+a+'/shCore.css" type="text/css">').appendTo($("head"));$('<link rel="stylesheet" href="'+a+"/shTheme"+this.theme+'.css" type="text/css">').appendTo($("head"));$.ajax({url:b+"/shCore.js",dataType:"script",async:false,success:shLoader.apply,})},apply:function(){if("undefined"==typeof(SyntaxHighlighter)){return}$(shLoader.loadURLs).each(function(b,c){$.ajax({url:c,dataType:"script",async:false,})});for(var a in this.configObj){SyntaxHighlighter.config[a]=this.configObj[a]}for(var a in this.defaultsObj){SyntaxHighlighter.defaults[a]=this.defaultsObj[a]}SyntaxHighlighter.all()},setDefaults:function(a){this.defaultsObj=a},setConfig:function(a){this.configObj=a},detectLanguages:function(){var a=[];var b=/brush: ?(\w+)/i;$(".brush\\:").each(function(){var d=$(this).attr("class");var c=d.match(b)[1];shLoader.reqLoad(c)})},reqLoad:function(b){var a=null;switch(b){case"cpp":case"c":case"c++":a="Cpp";break;case"c#":case"c-sharp":case"csharp":a="CSharp";break;case"css":a="Css";break;case"delphi":case"pascal":a="Delphi";break;case"java":a="Java";break;case"js":case"jscript":case"javascript":a="JScript";break;case"php":a="Php";break;case"py":case"python":a="Python";break;case"rb":case"ruby":case"rails":case"ror":a="Ruby";break;case"sql":a="Sql";break;case"vb":case"vb.net":a="Vb";break;case"xml":case"html":case"xhtml":case"xslt":a="Xml";break;default:}if(a){if(!this.loaded[a]){this.loadURLs[this.loadURLs.length]=this.path+"/sh/scripts/shBrush"+a+".js";this.loaded[a]=true}}},getDefaults:function(){return this.defaultsObj},getConfig:function(){return this.configObj},theme:"Default",path:"/wp-content/plugins/js-syntax-highlighter",loaded:[],loadURLs:[],configObj:{},defaultsObj:{},}; |
/wp-js-syntax-highlighter/trunk/loader.full.js |
---|
53,7 → 53,10 |
} |
$(document).ready(function() { shLoader.load(); }); |
}, // }}} // init() |
load: function() { // {{{ |
/** {{{ // load() Actually load SyntaxHighlighter, if required |
* Only if some code block is found it will be loaded. |
*/ |
load: function() { |
if (!jQuery) { return; } |
var cssPath = this.path+'/sh/styles'; |
var jsPath = this.path+'/sh/scripts'; |
76,10 → 79,17 |
$.ajax({ // Like jQuery.getScript() but in synchronous mode |
url: jsPath+'/shCore.js', |
dataType: 'script', |
async: false |
async: false, // If loaded asynchronously sh fails. Why? No clue. |
success: shLoader.apply, |
}); |
}, // }}} // load() |
apply: function() { // Initialise the SyntaxHighlighter plugin |
if ('undefined' == typeof(SyntaxHighlighter)) { |
// Something failed... |
return; |
} |
$(this.loadURLs).each(function (i,e) { |
$(shLoader.loadURLs).each(function (i,e) { |
$.ajax({ |
url: e, |
dataType: 'script', |
86,12 → 96,6 |
async: false, |
}); |
}); |
if ('undefined' == typeof(SyntaxHighlighter)) { |
// Something failed... |
return; |
} |
// Set any configuration and defaults |
for (var prop in this.configObj) { |
SyntaxHighlighter.config[prop] = this.configObj[prop]; |
100,9 → 104,9 |
SyntaxHighlighter.defaults[prop] = this.defaultsObj[prop]; |
} |
// FIXME: It won't load sometimes. Why? |
// FIXME: This used to fail on first load, it seems to fail from time to time now |
SyntaxHighlighter.all(); // Actually apply syntax highlighting |
}, // }}} // load() |
}, // }}} // apply() |
/** {{{ // setDefaults() // Sets the defaults object of SyntaxHighlighter |
* Note the defaults won't be applied until init() is called and SyntaxHighlighter |
* loaded. |
124,8 → 128,9 |
}, // }}} // setConfig |
detectLanguages: function() { // {{{ // Find any language used in the page |
var detected = []; |
var re = /brush: (\w+)/i; |
$('.brush\\:').each(function() { |
var re = /brush: ?(\w+)/i; |
//$('.brush\\:') would not match stuff like 'brush:css' (but it will match 'brush: css') |
$('[class^=brush:]').each(function() { |
var cn = $(this).attr('class'); |
var lang = cn.match(re)[1]; |
shLoader.reqLoad(lang); |
/wp-js-syntax-highlighter/trunk/plugin.php |
---|
5,7 → 5,7 |
* Plugin URI: http://p.outlyer.net./wordpress/ |
* Feed URI: |
* Description: Adds automatic syntax highlighting of code from JavaScript. Using Alex Gorbatchev's SyntaxHighlighter code. It requires jQuery to work properly, which will be loaded from javascript if not present. It tries to make it less intrusive and allow for valid XHTML. See js/loader.full.js for details. |
* Version: 0.4.0+3.0.83 |
* Version: 0.4.1+3.0.83 |
* Author: Toni Corvera |
* Author URI: http://corvera.eu./ |
*/ // $Id$ |
/wp-js-syntax-highlighter/trunk/ChangeLog.txt |
---|
10,6 → 10,8 |
* Allow complete initialisation and theming |
* Include SyntaxHighlighter version in version string |
* Added Makefile |
0.4.1: Delay call to SyntaxHighlighter.all() further |
0.4.1: Allow no-space between brush and language in class |
0.3.0 (2010-12-06): |
* Port loader to jQuery instead of base2.DOM |
/wp-js-syntax-highlighter/trunk/. |
---|
Property changes: |
Modified: svn:mergeinfo |
Merged /wp-js-syntax-highlighter/branches/0.4.1+3.0.83:r105 |