mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-25 04:24:45 -04:00
Loads SyntaxHighlighter on demand.
This commit is contained in:
parent
d4a213beac
commit
298d2e2efd
5 changed files with 57 additions and 22 deletions
|
@ -6,7 +6,7 @@ var path = require('path'),
|
|||
child_process = require('child_process');
|
||||
|
||||
|
||||
var version = '0.21-dev-43',
|
||||
var version = '0.21-dev-45',
|
||||
|
||||
root = path.resolve(__dirname),
|
||||
src = path.join(root, 'src'),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
modulejs.define('ext/preview-txt', ['_', '$', 'sh', 'core/settings', 'core/resource', 'core/store', 'core/entry'], function (_, $, SH, allsettings, resource, store, entry) {
|
||||
modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource', 'core/store', 'core/entry'], function (_, $, allsettings, resource, store, entry) {
|
||||
|
||||
var defaults = {
|
||||
enabled: false,
|
||||
|
@ -34,6 +34,24 @@ modulejs.define('ext/preview-txt', ['_', '$', 'sh', 'core/settings', 'core/resou
|
|||
currentEntries = [],
|
||||
currentIdx = 0,
|
||||
|
||||
loadSyntaxhighlighter = function (callback) {
|
||||
|
||||
var id = 'SyntaxHighlighter';
|
||||
|
||||
if (window[id]) {
|
||||
callback(window[id]);
|
||||
} else {
|
||||
$.ajax({
|
||||
url: allsettings.h5aiAbsHref + 'js/syntaxhighlighter.js',
|
||||
dataType: 'script',
|
||||
complete: function () {
|
||||
|
||||
callback(window[id]);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
adjustSize = function () {
|
||||
|
||||
var rect = $(window).fracs('viewport'),
|
||||
|
@ -94,7 +112,12 @@ modulejs.define('ext/preview-txt', ['_', '$', 'sh', 'core/settings', 'core/resou
|
|||
var $nText = $(templateText).hide().addClass('toolbar: false; brush:').addClass(settings.types[current.type] || 'plain').text(content);
|
||||
|
||||
$text.replaceWith($nText);
|
||||
SH.highlight({}, $nText[0]);
|
||||
loadSyntaxhighlighter(function (sh) {
|
||||
|
||||
if (sh) {
|
||||
sh.highlight({}, $nText[0]);
|
||||
}
|
||||
});
|
||||
$nText.fadeIn(200);
|
||||
|
||||
adjustSize();
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
|
||||
$(function () {
|
||||
/*global H5AI_CONFIG, amplify, Base64, jQuery, Modernizr, moment, SyntaxHighlighter, _ */
|
||||
/*global H5AI_CONFIG, amplify, Base64, jQuery, Modernizr, moment, _ */
|
||||
|
||||
// Register predefined globals on doc ready, so the script order inside
|
||||
// the document doesn't matter. `jQuery`, `moment` and `underscore` are
|
||||
|
@ -59,7 +59,6 @@
|
|||
modulejs.define('$', function () { return jQuery; });
|
||||
modulejs.define('modernizr', Modernizr);
|
||||
modulejs.define('moment', function () { return moment; });
|
||||
modulejs.define('sh', SyntaxHighlighter);
|
||||
modulejs.define('_', function () { return _; });
|
||||
|
||||
modulejs.require($('body').attr('id'));
|
||||
|
|
|
@ -17,23 +17,6 @@
|
|||
// @include "lib/base64.js"
|
||||
// @include "lib/spin-1.2.5.min.js"
|
||||
|
||||
// @include "lib/sh/shCore.js"
|
||||
// @include "lib/sh/shBrushBash.js"
|
||||
// @include "lib/sh/shBrushCSharp.js"
|
||||
// @include "lib/sh/shBrushCpp.js"
|
||||
// @include "lib/sh/shBrushCss.js"
|
||||
// @include "lib/sh/shBrushDiff.js"
|
||||
// @include "lib/sh/shBrushJScript.js"
|
||||
// @include "lib/sh/shBrushJava.js"
|
||||
// @include "lib/sh/shBrushPerl.js"
|
||||
// @include "lib/sh/shBrushPhp.js"
|
||||
// @include "lib/sh/shBrushPlain.js"
|
||||
// @include "lib/sh/shBrushPython.js"
|
||||
// @include "lib/sh/shBrushRuby.js"
|
||||
// @include "lib/sh/shBrushSass.js"
|
||||
// @include "lib/sh/shBrushXml.js"
|
||||
|
||||
|
||||
// h5ai
|
||||
// ----
|
||||
// @include "inc/main.js"
|
||||
|
|
30
src/_h5ai/js/syntaxhighlighter.js
Normal file
30
src/_h5ai/js/syntaxhighlighter.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
// @include "lib/sh/shCore.js"
|
||||
// @-include "lib/sh/shLegacy.js"
|
||||
// @-include "lib/sh/shAutoloader.js"
|
||||
|
||||
// @include "lib/sh/shBrushAS3.js"
|
||||
// @include "lib/sh/shBrushAppleScript.js"
|
||||
// @include "lib/sh/shBrushBash.js"
|
||||
// @include "lib/sh/shBrushCSharp.js"
|
||||
// @include "lib/sh/shBrushColdFusion.js"
|
||||
// @include "lib/sh/shBrushCpp.js"
|
||||
// @include "lib/sh/shBrushCss.js"
|
||||
// @include "lib/sh/shBrushDelphi.js"
|
||||
// @include "lib/sh/shBrushDiff.js"
|
||||
// @include "lib/sh/shBrushErlang.js"
|
||||
// @include "lib/sh/shBrushGroovy.js"
|
||||
// @include "lib/sh/shBrushJScript.js"
|
||||
// @include "lib/sh/shBrushJava.js"
|
||||
// @include "lib/sh/shBrushJavaFX.js"
|
||||
// @include "lib/sh/shBrushPerl.js"
|
||||
// @include "lib/sh/shBrushPhp.js"
|
||||
// @include "lib/sh/shBrushPlain.js"
|
||||
// @include "lib/sh/shBrushPowerShell.js"
|
||||
// @include "lib/sh/shBrushPython.js"
|
||||
// @include "lib/sh/shBrushRuby.js"
|
||||
// @include "lib/sh/shBrushSass.js"
|
||||
// @include "lib/sh/shBrushScala.js"
|
||||
// @include "lib/sh/shBrushSql.js"
|
||||
// @include "lib/sh/shBrushVb.js"
|
||||
// @include "lib/sh/shBrushXml.js"
|
Loading…
Add table
Add a link
Reference in a new issue