All Downloads are FREE. Search and download functionalities are using the official Maven repository.

z_build.needed_by_javadoc.shCore.js Maven / Gradle / Ivy

Go to download

**Codelet**: Automated insertion of *already unit-tested* example code (its source code, console output, and input text-files) into JavaDoc using inline taglets--Codelet makes it possible to have *always accurate documentation*.

There is a newer version: 0.1.4.1
Show newest version
/**
 * SyntaxHighlighter
 * http://alexgorbatchev.com/SyntaxHighlighter
 *
 * SyntaxHighlighter is donationware. If you are using it, please donate.
 * http://alexgorbatchev.com/SyntaxHighlighter/donate.html
 *
 * @version
 * 3.0.83 (July 02 2010)
 * 
 * @copyright
 * Copyright (C) 2004-2010 Alex Gorbatchev.
 *
 * @license
 * Dual licensed under the MIT and GPL licenses.
 */
//
// Begin anonymous function. This is used to contain local scope variables without polutting global scope.
//
var SyntaxHighlighter = function() { 

// CommonJS
if (typeof(require) != 'undefined' && typeof(XRegExp) == 'undefined')
{
	XRegExp = require('XRegExp').XRegExp;
}

// Shortcut object which will be assigned to the SyntaxHighlighter variable.
// This is a shorthand for local reference in order to avoid long namespace 
// references to SyntaxHighlighter.whatever...
var sh = {
	defaults : {
		/** Additional CSS class names to be added to highlighter elements. */
		'class-name' : '',
		
		/** First line number. */
		'first-line' : 1,
		
		/**
		 * Pads line numbers. Possible values are:
		 *
		 *   false - don't pad line numbers.
		 *   true  - automaticaly pad numbers with minimum required number of leading zeroes.
		 *   [int] - length up to which pad line numbers.
		 */
		'pad-line-numbers' : false,
		
		/** Lines to highlight. */
		'highlight' : null,
		
		/** Title to be displayed above the code block. */
		'title' : null,
		
		/** Enables or disables smart tabs. */
		'smart-tabs' : true,
		
		/** Gets or sets tab size. */
		'tab-size' : 4,
		
		/** Enables or disables gutter. */
		'gutter' : true,
		
		/** Enables or disables toolbar. */
		'toolbar' : true,
		
		/** Enables quick code copy and paste from double click. */
		'quick-code' : true,
		
		/** Forces code view to be collapsed. */
		'collapse' : false,
		
		/** Enables or disables automatic links. */
		'auto-links' : true,
		
		/** Gets or sets light mode. Equavalent to turning off gutter and toolbar. */
		'light' : false,
		
		'html-script' : false
	},
	
	config : {
		space : ' ',
		
		/** Enables use of  tags. */
		scriptScriptTags			: { left: /(<|<)\s*script.*?(>|>)/gi, right: /(<|<)\/\s*script\s*(>|>)/gi }
	},

	toolbar: {
		/**
		 * Generates HTML markup for the toolbar.
		 * @param {Highlighter} highlighter Highlighter instance.
		 * @return {String} Returns HTML markup.
		 */
		getHtml: function(highlighter)
		{
			var html = '
', items = sh.toolbar.items, list = items.list ; function defaultGetHtml(highlighter, name) { return sh.toolbar.getButtonHtml(highlighter, name, sh.config.strings[name]); }; for (var i = 0; i < list.length; i++) html += (items[list[i]].getHtml || defaultGetHtml)(highlighter, list[i]); html += '
'; return html; }, /** * Generates HTML markup for a regular button in the toolbar. * @param {Highlighter} highlighter Highlighter instance. * @param {String} commandName Command name that would be executed. * @param {String} label Label text to display. * @return {String} Returns HTML markup. */ getButtonHtml: function(highlighter, commandName, label) { return '' + label + '' ; }, /** * Event handler for a toolbar anchor. */ handler: function(e) { var target = e.target, className = target.className || '' ; function getValue(name) { var r = new RegExp(name + '_(\\w+)'), match = r.exec(className) ; return match ? match[1] : null; }; var highlighter = getHighlighterById(findParentElement(target, '.syntaxhighlighter').id), commandName = getValue('command') ; // execute the toolbar command if (highlighter && commandName) sh.toolbar.items[commandName].execute(highlighter); // disable default A click behaviour e.preventDefault(); }, /** Collection of toolbar items. */ items : { // Ordered lis of items in the toolbar. Can't expect `for (var n in items)` to be consistent. list: ['expandSource', 'help'], expandSource: { getHtml: function(highlighter) { if (highlighter.getParam('collapse') != true) return ''; var title = highlighter.getParam('title'); return sh.toolbar.getButtonHtml(highlighter, 'expandSource', title ? title : sh.config.strings.expandSource); }, execute: function(highlighter) { var div = getHighlighterDivById(highlighter.id); removeClass(div, 'collapsed'); } }, /** Command to display the about dialog window. */ help: { execute: function(highlighter) { var wnd = popup('', '_blank', 500, 250, 'scrollbars=0'), doc = wnd.document ; doc.write(sh.config.strings.aboutDialog); doc.close(); wnd.focus(); } } } }, /** * Finds all elements on the page which should be processes by SyntaxHighlighter. * * @param {Object} globalParams Optional parameters which override element's * parameters. Only used if element is specified. * * @param {Object} element Optional element to highlight. If none is * provided, all elements in the current document * are returned which qualify. * * @return {Array} Returns list of { target: DOMElement, params: Object } objects. */ findElements: function(globalParams, element) { var elements = element ? [element] : toArray(document.getElementsByTagName(sh.config.tagName)), conf = sh.config, result = [] ; // support for