├── .gitignore ├── Change.log ├── demos └── demo.html ├── docs ├── Matrix.html ├── classes.list.html ├── img │ ├── glyphicons-halflings-white.png │ └── glyphicons-halflings.png ├── index.html ├── scripts │ ├── URI.js │ ├── bootstrap-dropdown.js │ ├── bootstrap-tab.js │ ├── jquery.localScroll.js │ ├── jquery.min.js │ ├── jquery.scrollTo.js │ ├── jquery.sunlight.js │ ├── prettify │ │ ├── Apache-License-2.0.txt │ │ ├── jquery.min.js │ │ ├── lang-css.js │ │ └── prettify.js │ ├── sunlight-plugin.doclinks.js │ ├── sunlight-plugin.linenumbers.js │ ├── sunlight-plugin.menu.js │ ├── sunlight.javascript.js │ ├── sunlight.js │ └── toc.js └── styles │ ├── darkstrap.css │ ├── prettify-tomorrow.css │ ├── site.cerulean.css │ └── sunlight.default.css ├── matrix.min.js ├── readme.md └── src └── matrix.js /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | docsmd 3 | outline 4 | tuts 5 | create-docs.* 6 | _* 7 | Project_TODO.txt 8 | -------------------------------------------------------------------------------- /Change.log: -------------------------------------------------------------------------------- 1 | Change log for 2D Transformation Matrix 2 | --------------------------------------- 3 | 4 | 1.5 5 | 6 | ADD: new method applyToTypedArray() 7 | CHG: Code restructured to "minify" better (github.com/leeoniya). 8 | FIX: applyToArray(), thanks to github.com/leeoniya for his contributions to this update 9 | 10 | 11 | 1.4 12 | 13 | ADD: Made non-returning methods chain-able. 14 | 15 | 16 | 1.3 17 | 18 | ADD: New method applyToContext(). 19 | 20 | 21 | 1.2 22 | 23 | ADD: Two new helper methods flipX() and flipY() 24 | ADD: Two new helper methods skewX() and skewY() 25 | ADD: Two new helper methods scaleX() and scaleY() 26 | ADD: Two new helper methods translateX() and translateY() 27 | ADD: Helper method rotateDeg() to rotate by degrees 28 | ADD: New method isEqual() to compare current matrix with another matrix 29 | CHG: getInverse() and interpolate() no longer apply parent's context to returned matrix 30 | CHG: Epsilon tolerance for floating point equal checks 31 | REM: Previous (partly experimental) added methods for add/subtract removed due to non-linear nature. 32 | 33 | 34 | 1.1 35 | 36 | ADD: New method reset() 37 | ADD: New method add() (obsoleted) 38 | ADD: New method addMatrix() (obsoleted) 39 | ADD: New method subtract() (obsoleted) 40 | ADD: New method subtractMatrix() (obsoleted) 41 | CHG: NOTE: Method applyToPoint() takes pair of x/y instead of point object 42 | CHG: Method applyToArray() can now take two forms of arrays (point objects and point pair values) 43 | FIX: If context is provided it will now be initialized to identity matrix to enable 100% sync 44 | FIX: Some documentation errors 45 | 46 | 47 | 1.0 48 | 49 | Initial release 50 | -------------------------------------------------------------------------------- /demos/demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 2D Affine Transformation Matrix demo 8 | 9 | 19 | 20 | 21 | 22 |
23 |
24 |

2D Affine Transformation Matrix

25 |
26 | 27 |
28 |

Synchronizing a canvas context by applying various transformations, 29 | then apply those to four points for a rectangle.

30 |

The manually transformed rectangle is drawn on top in blue transparent of the canvas transformed 31 | rectangle in red to show they are in perfect sync.

32 | 33 |

Sorry, need a modern browser...

34 |
35 |
36 | 37 | 40 |
41 | 42 | 43 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /docs/classes.list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Matrix Classes 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 42 | 43 |
44 | 45 | 46 |
47 | 48 |
49 | 50 | 51 | 52 |

Classes

53 |
54 | 55 |
56 |

57 | 58 |

59 | 60 |
61 | 62 |
63 |
64 | 65 | 66 | 67 | 68 | 69 | 70 |
71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 |
95 | 96 | 97 | 98 | 99 |
100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 |

Classes

109 | 110 |
111 |
Matrix
112 |
113 |
114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 |
126 | 127 |
128 | 129 | 130 | 131 | 132 |
133 | 134 |
135 | 148 |
149 | 150 | 151 |
152 |
153 |
154 | 155 |
156 |
157 | 158 |
159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /docs/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leeoniya/transformation-matrix-js/3595d2b36aa1b0f593bdffdb786b9e832c50c3b0/docs/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /docs/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leeoniya/transformation-matrix-js/3595d2b36aa1b0f593bdffdb786b9e832c50c3b0/docs/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Matrix Index 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 42 | 43 |
44 | 45 | 46 |
47 | 48 |
49 | 50 | 51 | 52 | 53 | Index 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
76 |

2D Affine Transformation Matrix

A affine transformation matrix (3x3) class for JavaScript that performs 77 | various transformations such as rotate, scale, translate, skew, add, subtract 78 | and multiply.

79 |

It's intended for situations where you need to track or create transforms 80 | and want to apply it permanently to your own points.

81 |

The matrix can optionally synchronize a canvas 2D context object so the transformations 82 | on the canvas matches pixel perfect the local transformations of the Matrix object.

83 |

No dependencies.

84 |

Usage

Just include the script and create a new instance like:

85 |
var matrix = new Matrix([context]);

You can supply an optional context as argument which in case will be 86 | synchronized with the transformations that are applied to the matrix 87 | object.

88 |

You can now apply transformations:

89 |
matrix.rotate(angle);                    // angle in radians
 90 | matrix.rotateDeg(angle);                   // angle in degrees
 91 | matrix.translate(x, y);
 92 | matrix.translateX(x);
 93 | matrix.translateY(y);
 94 | matrix.scale(sx, sy);
 95 | matrix.scaleX(sx);
 96 | matrix.scaleY(sy);
 97 | matrix.skew(sx, sy);
 98 | matrix.skewX(sx);
 99 | matrix.skewY(sy);
100 | matrix.transform(a, b, c, d, e, f);
101 | matrix.setTransform(a, b, c, d, e, f);
102 | matrix.reset();

Get current transform matrix values:

103 |
var a = matrix.a;    // scale x
104 | var b = matrix.b;    // skew y
105 | var c = matrix.c;    // skew x
106 | var d = matrix.d;    // scale y
107 | var e = matrix.e;    // translate x
108 | var f = matrix.f;    // translate y

Apply to a point:

109 |
var tPoint = matrix.applyToPoint(x, y);

Apply to an Array with point objects or point pair values:

110 |
var tPoints = matrix.applyToArray([{x: x1, y: y1}, {x: x2, y: y2}, ...]);
111 | var tPoints = matrix.applyToArray([x1, y1, x2, y2, ...]);
112 | var tPoints = matrix.applyToTypedArray(...);

or apply to a canvas context (other than optionally referenced in constructor):

113 |
matrix.applyToContext(myContext);

Get inverse transformation matrix (the matrix you need to apply to get back 114 | to a identity matrix from whatever the matrix contains):

115 |
var invmatrix = matrix.getInverse();

You can interpolate between current and a new matrix. The function 116 | returns a new matrix:

117 |
var imatrix = matrix.interpolate(matrix2, t);  // t = [0.0, 1.0]

Check if there is any transforms applied:

118 |
var status = matrix.isIdentity();              // true if identity

Check if two matrices are identical:

119 |
var status = matrix.isEqual(matrix2);          // true if equal

Reset matrix to an identity matrix:

120 |
matrix.reset();

Methods are also chain-able:

121 |
matrix.rotateDeg(45).translate(100, 120);     // rotate, then translate

See documentation for full overview and usage.

122 |

License

Released under MIT license. You can use this class in both commercial and non-commercial projects provided that full header (minified and developer versions) is included.

123 |

© 2014 Epistmex

124 |

Epistemex

125 |
126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 |
134 | 135 |
136 | 149 |
150 | 151 | 152 |
153 |
154 |
155 | 156 |
157 |
158 | 159 |
160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 189 | 190 | 191 | 192 | 193 | -------------------------------------------------------------------------------- /docs/scripts/bootstrap-dropdown.js: -------------------------------------------------------------------------------- 1 | /* ============================================================ 2 | * bootstrap-dropdown.js v2.3.1 3 | * http://twitter.github.com/bootstrap/javascript.html#dropdowns 4 | * ============================================================ 5 | * Copyright 2012 Twitter, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ============================================================ */ 19 | 20 | 21 | !function ($) { 22 | 23 | "use strict"; // jshint ;_; 24 | 25 | 26 | /* DROPDOWN CLASS DEFINITION 27 | * ========================= */ 28 | 29 | var toggle = '[data-toggle=dropdown]' 30 | , Dropdown = function (element) { 31 | var $el = $(element).on('click.dropdown.data-api', this.toggle) 32 | $('html').on('click.dropdown.data-api', function () { 33 | $el.parent().removeClass('open') 34 | }) 35 | } 36 | 37 | Dropdown.prototype = { 38 | 39 | constructor: Dropdown 40 | 41 | , toggle: function (e) { 42 | var $this = $(this) 43 | , $parent 44 | , isActive 45 | 46 | if ($this.is('.disabled, :disabled')) return 47 | 48 | $parent = getParent($this) 49 | 50 | isActive = $parent.hasClass('open') 51 | 52 | clearMenus() 53 | 54 | if (!isActive) { 55 | $parent.toggleClass('open') 56 | } 57 | 58 | $this.focus() 59 | 60 | return false 61 | } 62 | 63 | , keydown: function (e) { 64 | var $this 65 | , $items 66 | , $active 67 | , $parent 68 | , isActive 69 | , index 70 | 71 | if (!/(38|40|27)/.test(e.keyCode)) return 72 | 73 | $this = $(this) 74 | 75 | e.preventDefault() 76 | e.stopPropagation() 77 | 78 | if ($this.is('.disabled, :disabled')) return 79 | 80 | $parent = getParent($this) 81 | 82 | isActive = $parent.hasClass('open') 83 | 84 | if (!isActive || (isActive && e.keyCode == 27)) { 85 | if (e.which == 27) $parent.find(toggle).focus() 86 | return $this.click() 87 | } 88 | 89 | $items = $('[role=menu] li:not(.divider):visible a', $parent) 90 | 91 | if (!$items.length) return 92 | 93 | index = $items.index($items.filter(':focus')) 94 | 95 | if (e.keyCode == 38 && index > 0) index-- // up 96 | if (e.keyCode == 40 && index < $items.length - 1) index++ // down 97 | if (!~index) index = 0 98 | 99 | $items 100 | .eq(index) 101 | .focus() 102 | } 103 | 104 | } 105 | 106 | function clearMenus() { 107 | $(toggle).each(function () { 108 | getParent($(this)).removeClass('open') 109 | }) 110 | } 111 | 112 | function getParent($this) { 113 | var selector = $this.attr('data-target') 114 | , $parent 115 | 116 | if (!selector) { 117 | selector = $this.attr('href') 118 | selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 119 | } 120 | 121 | $parent = selector && $(selector) 122 | 123 | if (!$parent || !$parent.length) $parent = $this.parent() 124 | 125 | return $parent 126 | } 127 | 128 | 129 | /* DROPDOWN PLUGIN DEFINITION 130 | * ========================== */ 131 | 132 | var old = $.fn.dropdown 133 | 134 | $.fn.dropdown = function (option) { 135 | return this.each(function () { 136 | var $this = $(this) 137 | , data = $this.data('dropdown') 138 | if (!data) $this.data('dropdown', (data = new Dropdown(this))) 139 | if (typeof option == 'string') data[option].call($this) 140 | }) 141 | } 142 | 143 | $.fn.dropdown.Constructor = Dropdown 144 | 145 | 146 | /* DROPDOWN NO CONFLICT 147 | * ==================== */ 148 | 149 | $.fn.dropdown.noConflict = function () { 150 | $.fn.dropdown = old 151 | return this 152 | } 153 | 154 | 155 | /* APPLY TO STANDARD DROPDOWN ELEMENTS 156 | * =================================== */ 157 | 158 | $(document) 159 | .on('click.dropdown.data-api', clearMenus) 160 | .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) 161 | .on('click.dropdown-menu', function (e) { e.stopPropagation() }) 162 | .on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle) 163 | .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) 164 | 165 | }(window.jQuery); 166 | -------------------------------------------------------------------------------- /docs/scripts/bootstrap-tab.js: -------------------------------------------------------------------------------- 1 | /* ======================================================== 2 | * bootstrap-tab.js v2.3.0 3 | * http://twitter.github.com/bootstrap/javascript.html#tabs 4 | * ======================================================== 5 | * Copyright 2012 Twitter, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ======================================================== */ 19 | 20 | 21 | !function ($) { 22 | 23 | "use strict"; // jshint ;_; 24 | 25 | 26 | /* TAB CLASS DEFINITION 27 | * ==================== */ 28 | 29 | var Tab = function (element) { 30 | this.element = $(element) 31 | } 32 | 33 | Tab.prototype = { 34 | 35 | constructor: Tab 36 | 37 | , show: function () { 38 | var $this = this.element 39 | , $ul = $this.closest('ul:not(.dropdown-menu)') 40 | , selector = $this.attr('data-target') 41 | , previous 42 | , $target 43 | , e 44 | 45 | if (!selector) { 46 | selector = $this.attr('href') 47 | selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 48 | } 49 | 50 | if ( $this.parent('li').hasClass('active') ) return 51 | 52 | previous = $ul.find('.active:last a')[0] 53 | 54 | e = $.Event('show', { 55 | relatedTarget: previous 56 | }) 57 | 58 | $this.trigger(e) 59 | 60 | if (e.isDefaultPrevented()) return 61 | 62 | $target = $(selector) 63 | 64 | this.activate($this.parent('li'), $ul) 65 | this.activate($target, $target.parent(), function () { 66 | $this.trigger({ 67 | type: 'shown' 68 | , relatedTarget: previous 69 | }) 70 | }) 71 | } 72 | 73 | , activate: function ( element, container, callback) { 74 | var $active = container.find('> .active') 75 | , transition = callback 76 | && $.support.transition 77 | && $active.hasClass('fade') 78 | 79 | function next() { 80 | $active 81 | .removeClass('active') 82 | .find('> .dropdown-menu > .active') 83 | .removeClass('active') 84 | 85 | element.addClass('active') 86 | 87 | if (transition) { 88 | element[0].offsetWidth // reflow for transition 89 | element.addClass('in') 90 | } else { 91 | element.removeClass('fade') 92 | } 93 | 94 | if ( element.parent('.dropdown-menu') ) { 95 | element.closest('li.dropdown').addClass('active') 96 | } 97 | 98 | callback && callback() 99 | } 100 | 101 | transition ? 102 | $active.one($.support.transition.end, next) : 103 | next() 104 | 105 | $active.removeClass('in') 106 | } 107 | } 108 | 109 | 110 | /* TAB PLUGIN DEFINITION 111 | * ===================== */ 112 | 113 | var old = $.fn.tab 114 | 115 | $.fn.tab = function ( option ) { 116 | return this.each(function () { 117 | var $this = $(this) 118 | , data = $this.data('tab') 119 | if (!data) $this.data('tab', (data = new Tab(this))) 120 | if (typeof option == 'string') data[option]() 121 | }) 122 | } 123 | 124 | $.fn.tab.Constructor = Tab 125 | 126 | 127 | /* TAB NO CONFLICT 128 | * =============== */ 129 | 130 | $.fn.tab.noConflict = function () { 131 | $.fn.tab = old 132 | return this 133 | } 134 | 135 | 136 | /* TAB DATA-API 137 | * ============ */ 138 | 139 | $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) { 140 | e.preventDefault() 141 | $(this).tab('show') 142 | }) 143 | 144 | }(window.jQuery); -------------------------------------------------------------------------------- /docs/scripts/jquery.localScroll.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery.LocalScroll 3 | * Copyright (c) 2007-2013 Ariel Flesler - afleslergmailcom | http://flesler.blogspot.com 4 | * Dual licensed under MIT and GPL. 5 | * http://flesler.blogspot.com/2007/10/jquerylocalscroll-10.html 6 | * @author Ariel Flesler 7 | * @version 1.2.8 8 | * 9 | * @id jQuery.fn.localScroll 10 | * @param {Object} settings Hash of settings, it is passed in to jQuery.ScrollTo, none is required. 11 | * @return {jQuery} Returns the same jQuery object, for chaining. 12 | * 13 | * @example $('ul.links').localScroll(); 14 | * 15 | * @example $('ul.links').localScroll({ filter:'.animated', duration:400, axis:'x' }); 16 | * 17 | * @example $.localScroll({ target:'#pane', axis:'xy', queue:true, event:'mouseover' }); 18 | * 19 | * Notes: 20 | * - The plugin requires jQuery.ScrollTo. 21 | * - The hash of settings, is passed to jQuery.ScrollTo, so the settings are valid for that plugin as well. 22 | * - jQuery.localScroll can be used if the desired links, are all over the document, it accepts the same settings. 23 | * - If the setting 'lazy' is set to true, then the binding will still work for later added anchors. 24 | * - If onBefore returns false, the event is ignored. 25 | */ 26 | ;(function( $ ){ 27 | var URI = location.href.replace(/#.*/,''); // local url without hash 28 | 29 | var $localScroll = $.localScroll = function( settings ){ 30 | $('body').localScroll( settings ); 31 | }; 32 | 33 | // Many of these defaults, belong to jQuery.ScrollTo, check it's demo for an example of each option. 34 | // @see http://flesler.demos.com/jquery/scrollTo/ 35 | // The defaults are public and can be overriden. 36 | $localScroll.defaults = { 37 | duration:1000, // How long to animate. 38 | axis:'y', // Which of top and left should be modified. 39 | event:'click', // On which event to react. 40 | stop:true, // Avoid queuing animations 41 | target: window, // What to scroll (selector or element). The whole window by default. 42 | reset: true // Used by $.localScroll.hash. If true, elements' scroll is resetted before actual scrolling 43 | /* 44 | lock:false, // ignore events if already animating 45 | lazy:false, // if true, links can be added later, and will still work. 46 | filter:null, // filter some anchors out of the matched elements. 47 | hash: false // if true, the hash of the selected link, will appear on the address bar. 48 | */ 49 | }; 50 | 51 | // If the URL contains a hash, it will scroll to the pointed element 52 | $localScroll.hash = function( settings ){ 53 | if( location.hash ){ 54 | settings = $.extend( {}, $localScroll.defaults, settings ); 55 | settings.hash = false; // can't be true 56 | 57 | if( settings.reset ){ 58 | var d = settings.duration; 59 | delete settings.duration; 60 | $(settings.target).scrollTo( 0, settings ); 61 | settings.duration = d; 62 | } 63 | scroll( 0, location, settings ); 64 | } 65 | }; 66 | 67 | $.fn.localScroll = function( settings ){ 68 | settings = $.extend( {}, $localScroll.defaults, settings ); 69 | 70 | return settings.lazy ? 71 | // use event delegation, more links can be added later. 72 | this.bind( settings.event, function( e ){ 73 | // Could use closest(), but that would leave out jQuery -1.3.x 74 | var a = $([e.target, e.target.parentNode]).filter(filter)[0]; 75 | // if a valid link was clicked 76 | if( a ) 77 | scroll( e, a, settings ); // do scroll. 78 | }) : 79 | // bind concretely, to each matching link 80 | this.find('a,area') 81 | .filter( filter ).bind( settings.event, function(e){ 82 | scroll( e, this, settings ); 83 | }).end() 84 | .end(); 85 | 86 | function filter(){// is this a link that points to an anchor and passes a possible filter ? href is checked to avoid a bug in FF. 87 | return !!this.href && !!this.hash && this.href.replace(this.hash,'') == URI && (!settings.filter || $(this).is( settings.filter )); 88 | }; 89 | }; 90 | 91 | function scroll( e, link, settings ){ 92 | var id = link.hash.slice(1), 93 | elem = document.getElementById(id) || document.getElementsByName(id)[0]; 94 | 95 | if ( !elem ) 96 | return; 97 | 98 | if( e ) 99 | e.preventDefault(); 100 | 101 | var $target = $( settings.target ); 102 | 103 | if( settings.lock && $target.is(':animated') || 104 | settings.onBefore && settings.onBefore(e, elem, $target) === false ) 105 | return; 106 | 107 | if( settings.stop ) 108 | $target._scrollable().stop(true); // remove all its animations 109 | 110 | if( settings.hash ){ 111 | var attr = elem.id == id ? 'id' : 'name', 112 | $a = $(' ').attr(attr, id).css({ 113 | position:'absolute', 114 | top: $(window).scrollTop(), 115 | left: $(window).scrollLeft() 116 | }); 117 | 118 | elem[attr] = ''; 119 | $('body').prepend($a); 120 | location = link.hash; 121 | $a.remove(); 122 | elem[attr] = id; 123 | } 124 | 125 | $target 126 | .scrollTo( elem, settings ) // do scroll 127 | .trigger('notify.serialScroll',[elem]); // notify serialScroll about this change 128 | }; 129 | 130 | })( jQuery ); -------------------------------------------------------------------------------- /docs/scripts/jquery.scrollTo.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery.ScrollTo 3 | * Copyright (c) 2007-2013 Ariel Flesler - afleslergmailcom | http://flesler.blogspot.com 4 | * Dual licensed under MIT and GPL. 5 | * 6 | * @projectDescription Easy element scrolling using jQuery. 7 | * http://flesler.blogspot.com/2007/10/jqueryscrollto.html 8 | * @author Ariel Flesler 9 | * @version 1.4.5 10 | * 11 | * @id jQuery.scrollTo 12 | * @id jQuery.fn.scrollTo 13 | * @param {String, Number, DOMElement, jQuery, Object} target Where to scroll the matched elements. 14 | * The different options for target are: 15 | * - A number position (will be applied to all axes). 16 | * - A string position ('44', '100px', '+=90', etc ) will be applied to all axes 17 | * - A jQuery/DOM element ( logically, child of the element to scroll ) 18 | * - A string selector, that will be relative to the element to scroll ( 'li:eq(2)', etc ) 19 | * - A hash { top:x, left:y }, x and y can be any kind of number/string like above. 20 | * - A percentage of the container's dimension/s, for example: 50% to go to the middle. 21 | * - The string 'max' for go-to-end. 22 | * @param {Number, Function} duration The OVERALL length of the animation, this argument can be the settings object instead. 23 | * @param {Object,Function} settings Optional set of settings or the onAfter callback. 24 | * @option {String} axis Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'. 25 | * @option {Number, Function} duration The OVERALL length of the animation. 26 | * @option {String} easing The easing method for the animation. 27 | * @option {Boolean} margin If true, the margin of the target element will be deducted from the final position. 28 | * @option {Object, Number} offset Add/deduct from the end position. One number for both axes or { top:x, left:y }. 29 | * @option {Object, Number} over Add/deduct the height/width multiplied by 'over', can be { top:x, left:y } when using both axes. 30 | * @option {Boolean} queue If true, and both axis are given, the 2nd axis will only be animated after the first one ends. 31 | * @option {Function} onAfter Function to be called after the scrolling ends. 32 | * @option {Function} onAfterFirst If queuing is activated, this function will be called after the first scrolling ends. 33 | * @return {jQuery} Returns the same jQuery object, for chaining. 34 | * 35 | * @desc Scroll to a fixed position 36 | * @example $('div').scrollTo( 340 ); 37 | * 38 | * @desc Scroll relatively to the actual position 39 | * @example $('div').scrollTo( '+=340px', { axis:'y' } ); 40 | * 41 | * @desc Scroll using a selector (relative to the scrolled element) 42 | * @example $('div').scrollTo( 'p.paragraph:eq(2)', 500, { easing:'swing', queue:true, axis:'xy' } ); 43 | * 44 | * @desc Scroll to a DOM element (same for jQuery object) 45 | * @example var second_child = document.getElementById('container').firstChild.nextSibling; 46 | * $('#container').scrollTo( second_child, { duration:500, axis:'x', onAfter:function(){ 47 | * alert('scrolled!!'); 48 | * }}); 49 | * 50 | * @desc Scroll on both axes, to different values 51 | * @example $('div').scrollTo( { top: 300, left:'+=200' }, { axis:'xy', offset:-20 } ); 52 | */ 53 | 54 | ;(function( $ ){ 55 | 56 | var $scrollTo = $.scrollTo = function( target, duration, settings ){ 57 | $(window).scrollTo( target, duration, settings ); 58 | }; 59 | 60 | $scrollTo.defaults = { 61 | axis:'xy', 62 | duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1, 63 | limit:true 64 | }; 65 | 66 | // Returns the element that needs to be animated to scroll the window. 67 | // Kept for backwards compatibility (specially for localScroll & serialScroll) 68 | $scrollTo.window = function( scope ){ 69 | return $(window)._scrollable(); 70 | }; 71 | 72 | // Hack, hack, hack :) 73 | // Returns the real elements to scroll (supports window/iframes, documents and regular nodes) 74 | $.fn._scrollable = function(){ 75 | return this.map(function(){ 76 | var elem = this, 77 | isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) != -1; 78 | 79 | if( !isWin ) 80 | return elem; 81 | 82 | var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem; 83 | 84 | return /webkit/i.test(navigator.userAgent) || doc.compatMode == 'BackCompat' ? 85 | doc.body : 86 | doc.documentElement; 87 | }); 88 | }; 89 | 90 | $.fn.scrollTo = function( target, duration, settings ){ 91 | if( typeof duration == 'object' ){ 92 | settings = duration; 93 | duration = 0; 94 | } 95 | if( typeof settings == 'function' ) 96 | settings = { onAfter:settings }; 97 | 98 | if( target == 'max' ) 99 | target = 9e9; 100 | 101 | settings = $.extend( {}, $scrollTo.defaults, settings ); 102 | // Speed is still recognized for backwards compatibility 103 | duration = duration || settings.duration; 104 | // Make sure the settings are given right 105 | settings.queue = settings.queue && settings.axis.length > 1; 106 | 107 | if( settings.queue ) 108 | // Let's keep the overall duration 109 | duration /= 2; 110 | settings.offset = both( settings.offset ); 111 | settings.over = both( settings.over ); 112 | 113 | return this._scrollable().each(function(){ 114 | // Null target yields nothing, just like jQuery does 115 | if (target == null) return; 116 | 117 | var elem = this, 118 | $elem = $(elem), 119 | targ = target, toff, attr = {}, 120 | win = $elem.is('html,body'); 121 | 122 | switch( typeof targ ){ 123 | // A number will pass the regex 124 | case 'number': 125 | case 'string': 126 | if( /^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ) ){ 127 | targ = both( targ ); 128 | // We are done 129 | break; 130 | } 131 | // Relative selector, no break! 132 | targ = $(targ,this); 133 | if (!targ.length) return; 134 | case 'object': 135 | // DOMElement / jQuery 136 | if( targ.is || targ.style ) 137 | // Get the real position of the target 138 | toff = (targ = $(targ)).offset(); 139 | } 140 | $.each( settings.axis.split(''), function( i, axis ){ 141 | var Pos = axis == 'x' ? 'Left' : 'Top', 142 | pos = Pos.toLowerCase(), 143 | key = 'scroll' + Pos, 144 | old = elem[key], 145 | max = $scrollTo.max(elem, axis); 146 | 147 | if( toff ){// jQuery / DOMElement 148 | attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] ); 149 | 150 | // If it's a dom element, reduce the margin 151 | if( settings.margin ){ 152 | attr[key] -= parseInt(targ.css('margin'+Pos)) || 0; 153 | attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0; 154 | } 155 | 156 | attr[key] += settings.offset[pos] || 0; 157 | 158 | if( settings.over[pos] ) 159 | // Scroll to a fraction of its width/height 160 | attr[key] += targ[axis=='x'?'width':'height']() * settings.over[pos]; 161 | }else{ 162 | var val = targ[pos]; 163 | // Handle percentage values 164 | attr[key] = val.slice && val.slice(-1) == '%' ? 165 | parseFloat(val) / 100 * max 166 | : val; 167 | } 168 | 169 | // Number or 'number' 170 | if( settings.limit && /^\d+$/.test(attr[key]) ) 171 | // Check the limits 172 | attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max ); 173 | 174 | // Queueing axes 175 | if( !i && settings.queue ){ 176 | // Don't waste time animating, if there's no need. 177 | if( old != attr[key] ) 178 | // Intermediate animation 179 | animate( settings.onAfterFirst ); 180 | // Don't animate this axis again in the next iteration. 181 | delete attr[key]; 182 | } 183 | }); 184 | 185 | animate( settings.onAfter ); 186 | 187 | function animate( callback ){ 188 | $elem.animate( attr, duration, settings.easing, callback && function(){ 189 | callback.call(this, target, settings); 190 | }); 191 | }; 192 | 193 | }).end(); 194 | }; 195 | 196 | // Max scrolling position, works on quirks mode 197 | // It only fails (not too badly) on IE, quirks mode. 198 | $scrollTo.max = function( elem, axis ){ 199 | var Dim = axis == 'x' ? 'Width' : 'Height', 200 | scroll = 'scroll'+Dim; 201 | 202 | if( !$(elem).is('html,body') ) 203 | return elem[scroll] - $(elem)[Dim.toLowerCase()](); 204 | 205 | var size = 'client' + Dim, 206 | html = elem.ownerDocument.documentElement, 207 | body = elem.ownerDocument.body; 208 | 209 | return Math.max( html[scroll], body[scroll] ) 210 | - Math.min( html[size] , body[size] ); 211 | }; 212 | 213 | function both( val ){ 214 | return typeof val == 'object' ? val : { top:val, left:val }; 215 | }; 216 | 217 | })( jQuery ); -------------------------------------------------------------------------------- /docs/scripts/jquery.sunlight.js: -------------------------------------------------------------------------------- 1 | /** 2 | * jQuery plugin for Sunlight http://sunlightjs.com/ 3 | * 4 | * by Tommy Montgomery http://tmont.com/ 5 | * licensed under WTFPL http://sam.zoy.org/wtfpl/ 6 | */ 7 | (function($, window){ 8 | 9 | $.fn.sunlight = function(options) { 10 | var highlighter = new window.Sunlight.Highlighter(options); 11 | this.each(function() { 12 | highlighter.highlightNode(this); 13 | }); 14 | 15 | return this; 16 | }; 17 | 18 | }(jQuery, this)); -------------------------------------------------------------------------------- /docs/scripts/prettify/Apache-License-2.0.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /docs/scripts/prettify/lang-css.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([ 2 | ["pln", /^[\t\n\f\r ]+/, null, " \t\r\n "] 3 | ], [ 4 | ["str", /^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/, null], 5 | ["str", /^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/, null], 6 | ["lang-css-str", /^url\(([^"')]*)\)/i], 7 | ["kwd", /^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i, null], 8 | ["lang-css-kw", /^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i], 9 | ["com", /^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//], 10 | ["com", /^(?:<\!--|--\>)/], 11 | ["lit", /^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i], 12 | ["lit", /^#[\da-f]{3,6}/i], 13 | ["pln", /^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i], 14 | ["pun", /^[^\s\w"']+/] 15 | ]), ["css"]); 16 | PR.registerLangHandler(PR.createSimpleLexer([], [ 17 | ["kwd", /^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i] 18 | ]), ["css-kw"]); 19 | PR.registerLangHandler(PR.createSimpleLexer([], [ 20 | ["str", /^[^"')]+/] 21 | ]), ["css-str"]); -------------------------------------------------------------------------------- /docs/scripts/prettify/prettify.js: -------------------------------------------------------------------------------- 1 | var q = null; 2 | window.PR_SHOULD_USE_CONTINUATION = !0; 3 | (function() { 4 | function L(a) { 5 | function m(a) { 6 | var f = a.charCodeAt(0); 7 | if (f !== 92) return f; 8 | var b = a.charAt(1); 9 | return (f = r[b]) ? f : "0" <= b && b <= "7" ? parseInt(a.substring(1), 8) : b === "u" || b === "x" ? parseInt(a.substring(2), 16) : a.charCodeAt(1) 10 | } 11 | 12 | function e(a) { 13 | if (a < 32) return (a < 16 ? "\\x0" : "\\x") + a.toString(16); 14 | a = String.fromCharCode(a); 15 | if (a === "\\" || a === "-" || a === "[" || a === "]") a = "\\" + a; 16 | return a 17 | } 18 | 19 | function h(a) { 20 | for (var f = a.substring(1, a.length - 1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g), a = [], b = [], o = f[0] === "^", c = o ? 1 : 0, i = f.length; c < i; ++c) { 21 | var j = f[c]; 22 | if (/\\[bdsw]/i.test(j)) a.push(j); 23 | else { 24 | var j = m(j), 25 | d; 26 | c + 2 < i && "-" === f[c + 1] ? (d = m(f[c + 2]), c += 2) : d = j; 27 | b.push([j, d]); 28 | d < 65 || j > 122 || (d < 65 || j > 90 || b.push([Math.max(65, j) | 32, Math.min(d, 90) | 32]), d < 97 || j > 122 || b.push([Math.max(97, j) & -33, Math.min(d, 122) & -33])) 29 | } 30 | } 31 | b.sort(function(a, f) { 32 | return a[0] - f[0] || f[1] - a[1] 33 | }); 34 | f = []; 35 | j = [NaN, NaN]; 36 | for (c = 0; c < b.length; ++c) i = b[c], i[0] <= j[1] + 1 ? j[1] = Math.max(j[1], i[1]) : f.push(j = i); 37 | b = ["["]; 38 | o && b.push("^"); 39 | b.push.apply(b, a); 40 | for (c = 0; c < f.length; ++c) i = f[c], b.push(e(i[0])), i[1] > i[0] && (i[1] + 1 > i[0] && b.push("-"), b.push(e(i[1]))); 41 | b.push("]"); 42 | return b.join("") 43 | } 44 | 45 | function y(a) { 46 | for (var f = a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g), b = f.length, d = [], c = 0, i = 0; c < b; ++c) { 47 | var j = f[c]; 48 | j === "(" ? ++i : "\\" === j.charAt(0) && (j = +j.substring(1)) && j <= i && (d[j] = -1) 49 | } 50 | for (c = 1; c < d.length; ++c) - 1 === d[c] && (d[c] = ++t); 51 | for (i = c = 0; c < b; ++c) j = f[c], j === "(" ? (++i, d[i] === void 0 && (f[c] = "(?:")) : "\\" === j.charAt(0) && (j = +j.substring(1)) && j <= i && (f[c] = "\\" + d[i]); 52 | for (i = c = 0; c < b; ++c)"^" === f[c] && "^" !== f[c + 1] && (f[c] = ""); 53 | if (a.ignoreCase && s) for (c = 0; c < b; ++c) j = f[c], a = j.charAt(0), j.length >= 2 && a === "[" ? f[c] = h(j) : a !== "\\" && (f[c] = j.replace(/[A-Za-z]/g, function(a) { 54 | a = a.charCodeAt(0); 55 | return "[" + String.fromCharCode(a & -33, a | 32) + "]" 56 | })); 57 | return f.join("") 58 | } 59 | for (var t = 0, s = !1, l = !1, p = 0, d = a.length; p < d; ++p) { 60 | var g = a[p]; 61 | if (g.ignoreCase) l = !0; 62 | else if (/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi, ""))) { 63 | s = !0; 64 | l = !1; 65 | break 66 | } 67 | } 68 | for (var r = { 69 | b: 8, 70 | t: 9, 71 | n: 10, 72 | v: 11, 73 | f: 12, 74 | r: 13 75 | }, n = [], p = 0, d = a.length; p < d; ++p) { 76 | g = a[p]; 77 | if (g.global || g.multiline) throw Error("" + g); 78 | n.push("(?:" + y(g) + ")") 79 | } 80 | return RegExp(n.join("|"), l ? "gi" : "g") 81 | } 82 | 83 | function M(a) { 84 | function m(a) { 85 | switch (a.nodeType) { 86 | case 1: 87 | if (e.test(a.className)) break; 88 | for (var g = a.firstChild; g; g = g.nextSibling) m(g); 89 | g = a.nodeName; 90 | if ("BR" === g || "LI" === g) h[s] = "\n", t[s << 1] = y++, t[s++ << 1 | 1] = a; 91 | break; 92 | case 3: 93 | case 4: 94 | g = a.nodeValue, g.length && (g = p ? g.replace(/\r\n?/g, "\n") : g.replace(/[\t\n\r ]+/g, " "), h[s] = g, t[s << 1] = y, y += g.length, t[s++ << 1 | 1] = a) 95 | } 96 | } 97 | var e = /(?:^|\s)nocode(?:\s|$)/, 98 | h = [], 99 | y = 0, 100 | t = [], 101 | s = 0, 102 | l; 103 | a.currentStyle ? l = a.currentStyle.whiteSpace : window.getComputedStyle && (l = document.defaultView.getComputedStyle(a, q).getPropertyValue("white-space")); 104 | var p = l && "pre" === l.substring(0, 3); 105 | m(a); 106 | return { 107 | a: h.join("").replace(/\n$/, ""), 108 | c: t 109 | } 110 | } 111 | 112 | function B(a, m, e, h) { 113 | m && (a = { 114 | a: m, 115 | d: a 116 | }, e(a), h.push.apply(h, a.e)) 117 | } 118 | 119 | function x(a, m) { 120 | function e(a) { 121 | for (var l = a.d, p = [l, "pln"], d = 0, g = a.a.match(y) || [], r = {}, n = 0, z = g.length; n < z; ++n) { 122 | var f = g[n], 123 | b = r[f], 124 | o = void 0, 125 | c; 126 | if (typeof b === "string") c = !1; 127 | else { 128 | var i = h[f.charAt(0)]; 129 | if (i) o = f.match(i[1]), b = i[0]; 130 | else { 131 | for (c = 0; c < t; ++c) if (i = m[c], o = f.match(i[1])) { 132 | b = i[0]; 133 | break 134 | } 135 | o || (b = "pln") 136 | } 137 | if ((c = b.length >= 5 && "lang-" === b.substring(0, 5)) && !(o && typeof o[1] === "string")) c = !1, b = "src"; 138 | c || (r[f] = b) 139 | } 140 | i = d; 141 | d += f.length; 142 | if (c) { 143 | c = o[1]; 144 | var j = f.indexOf(c), 145 | k = j + c.length; 146 | o[2] && (k = f.length - o[2].length, j = k - c.length); 147 | b = b.substring(5); 148 | B(l + i, f.substring(0, j), e, p); 149 | B(l + i + j, c, C(b, c), p); 150 | B(l + i + k, f.substring(k), e, p) 151 | } else p.push(l + i, b) 152 | } 153 | a.e = p 154 | } 155 | var h = {}, 156 | y; 157 | (function() { 158 | for (var e = a.concat(m), l = [], p = {}, d = 0, g = e.length; d < g; ++d) { 159 | var r = e[d], 160 | n = r[3]; 161 | if (n) for (var k = n.length; --k >= 0;) h[n.charAt(k)] = r; 162 | r = r[1]; 163 | n = "" + r; 164 | p.hasOwnProperty(n) || (l.push(r), p[n] = q) 165 | } 166 | l.push(/[\S\s]/); 167 | y = L(l) 168 | })(); 169 | var t = m.length; 170 | return e 171 | } 172 | 173 | function u(a) { 174 | var m = [], 175 | e = []; 176 | a.tripleQuotedStrings ? m.push(["str", /^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/, q, "'\""]) : a.multiLineStrings ? m.push(["str", /^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, q, "'\"`"]) : m.push(["str", /^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/, q, "\"'"]); 177 | a.verbatimStrings && e.push(["str", /^@"(?:[^"]|"")*(?:"|$)/, q]); 178 | var h = a.hashComments; 179 | h && (a.cStyleComments ? (h > 1 ? m.push(["com", /^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/, q, "#"]) : m.push(["com", /^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/, q, "#"]), e.push(["str", /^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/, q])) : m.push(["com", /^#[^\n\r]*/, q, "#"])); 180 | a.cStyleComments && (e.push(["com", /^\/\/[^\n\r]*/, q]), e.push(["com", /^\/\*[\S\s]*?(?:\*\/|$)/, q])); 181 | a.regexLiterals && e.push(["lang-regex", /^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]); 182 | (h = a.types) && e.push(["typ", h]); 183 | a = ("" + a.keywords).replace(/^ | $/g, ""); 184 | a.length && e.push(["kwd", RegExp("^(?:" + a.replace(/[\s,]+/g, "|") + ")\\b"), q]); 185 | m.push(["pln", /^\s+/, q, " \r\n\t\xa0"]); 186 | e.push(["lit", /^@[$_a-z][\w$@]*/i, q], ["typ", /^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/, q], ["pln", /^[$_a-z][\w$@]*/i, q], ["lit", /^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i, q, "0123456789"], ["pln", /^\\[\S\s]?/, q], ["pun", /^.[^\s\w"-$'./@\\`]*/, q]); 187 | return x(m, e) 188 | } 189 | 190 | function D(a, m) { 191 | function e(a) { 192 | switch (a.nodeType) { 193 | case 1: 194 | if (k.test(a.className)) break; 195 | if ("BR" === a.nodeName) h(a), a.parentNode && a.parentNode.removeChild(a); 196 | else for (a = a.firstChild; a; a = a.nextSibling) e(a); 197 | break; 198 | case 3: 199 | case 4: 200 | if (p) { 201 | var b = a.nodeValue, 202 | d = b.match(t); 203 | if (d) { 204 | var c = b.substring(0, d.index); 205 | a.nodeValue = c; 206 | (b = b.substring(d.index + d[0].length)) && a.parentNode.insertBefore(s.createTextNode(b), a.nextSibling); 207 | h(a); 208 | c || a.parentNode.removeChild(a) 209 | } 210 | } 211 | } 212 | } 213 | 214 | function h(a) { 215 | function b(a, d) { 216 | var e = d ? a.cloneNode(!1) : a, 217 | f = a.parentNode; 218 | if (f) { 219 | var f = b(f, 1), 220 | g = a.nextSibling; 221 | f.appendChild(e); 222 | for (var h = g; h; h = g) g = h.nextSibling, f.appendChild(h) 223 | } 224 | return e 225 | } 226 | for (; !a.nextSibling;) if (a = a.parentNode, !a) return; 227 | for (var a = b(a.nextSibling, 0), e; 228 | (e = a.parentNode) && e.nodeType === 1;) a = e; 229 | d.push(a) 230 | } 231 | var k = /(?:^|\s)nocode(?:\s|$)/, 232 | t = /\r\n?|\n/, 233 | s = a.ownerDocument, 234 | l; 235 | a.currentStyle ? l = a.currentStyle.whiteSpace : window.getComputedStyle && (l = s.defaultView.getComputedStyle(a, q).getPropertyValue("white-space")); 236 | var p = l && "pre" === l.substring(0, 3); 237 | for (l = s.createElement("LI"); a.firstChild;) l.appendChild(a.firstChild); 238 | for (var d = [l], g = 0; g < d.length; ++g) e(d[g]); 239 | m === (m | 0) && d[0].setAttribute("value", m); 240 | var r = s.createElement("OL"); 241 | r.className = "linenums"; 242 | for (var n = Math.max(0, m - 1 | 0) || 0, g = 0, z = d.length; g < z; ++g) l = d[g], l.className = "L" + (g + n) % 10, l.firstChild || l.appendChild(s.createTextNode("\xa0")), r.appendChild(l); 243 | a.appendChild(r) 244 | } 245 | 246 | function k(a, m) { 247 | for (var e = m.length; --e >= 0;) { 248 | var h = m[e]; 249 | A.hasOwnProperty(h) ? window.console && console.warn("cannot override language handler %s", h) : A[h] = a 250 | } 251 | } 252 | 253 | function C(a, m) { 254 | if (!a || !A.hasOwnProperty(a)) a = /^\s*= o && (h += 2); 309 | e >= c && (a += 2) 310 | } 311 | } catch (w) { 312 | "console" in window && console.log(w && w.stack ? w.stack : w) 313 | } 314 | } 315 | var v = ["break,continue,do,else,for,if,return,while"], 316 | w = [ 317 | [v, "auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"], 318 | F = [w, "alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"], 319 | G = [w, "abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], 320 | H = [G, "as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"], 321 | w = [w, "debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"], 322 | I = [v, "and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], 323 | J = [v, "alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"], 324 | v = [v, "case,done,elif,esac,eval,fi,function,in,local,set,then,until"], 325 | K = /^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/, 326 | N = /\S/, 327 | O = u({ 328 | keywords: [F, H, w, "caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END" + I, J, v], 329 | hashComments: !0, 330 | cStyleComments: !0, 331 | multiLineStrings: !0, 332 | regexLiterals: !0 333 | }), 334 | A = {}; 335 | k(O, ["default-code"]); 336 | k(x([], [ 337 | ["pln", /^[^]*(?:>|$)/], 339 | ["com", /^<\!--[\S\s]*?(?:--\>|$)/], 340 | ["lang-", /^<\?([\S\s]+?)(?:\?>|$)/], 341 | ["lang-", /^<%([\S\s]+?)(?:%>|$)/], 342 | ["pun", /^(?:<[%?]|[%?]>)/], 343 | ["lang-", /^]*>([\S\s]+?)<\/xmp\b[^>]*>/i], 344 | ["lang-js", /^]*>([\S\s]*?)(<\/script\b[^>]*>)/i], 345 | ["lang-css", /^]*>([\S\s]*?)(<\/style\b[^>]*>)/i], 346 | ["lang-in.tag", /^(<\/?[a-z][^<>]*>)/i] 347 | ]), ["default-markup", "htm", "html", "mxml", "xhtml", "xml", "xsl"]); 348 | k(x([ 349 | ["pln", /^\s+/, q, " \t\r\n"], 350 | ["atv", /^(?:"[^"]*"?|'[^']*'?)/, q, "\"'"] 351 | ], [ 352 | ["tag", /^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i], 353 | ["atn", /^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i], 354 | ["lang-uq.val", /^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/], 355 | ["pun", /^[/<->]+/], 356 | ["lang-js", /^on\w+\s*=\s*"([^"]+)"/i], 357 | ["lang-js", /^on\w+\s*=\s*'([^']+)'/i], 358 | ["lang-js", /^on\w+\s*=\s*([^\s"'>]+)/i], 359 | ["lang-css", /^style\s*=\s*"([^"]+)"/i], 360 | ["lang-css", /^style\s*=\s*'([^']+)'/i], 361 | ["lang-css", /^style\s*=\s*([^\s"'>]+)/i] 362 | ]), ["in.tag"]); 363 | k(x([], [ 364 | ["atv", /^[\S\s]+/] 365 | ]), ["uq.val"]); 366 | k(u({ 367 | keywords: F, 368 | hashComments: !0, 369 | cStyleComments: !0, 370 | types: K 371 | }), ["c", "cc", "cpp", "cxx", "cyc", "m"]); 372 | k(u({ 373 | keywords: "null,true,false" 374 | }), ["json"]); 375 | k(u({ 376 | keywords: H, 377 | hashComments: !0, 378 | cStyleComments: !0, 379 | verbatimStrings: !0, 380 | types: K 381 | }), ["cs"]); 382 | k(u({ 383 | keywords: G, 384 | cStyleComments: !0 385 | }), ["java"]); 386 | k(u({ 387 | keywords: v, 388 | hashComments: !0, 389 | multiLineStrings: !0 390 | }), ["bsh", "csh", "sh"]); 391 | k(u({ 392 | keywords: I, 393 | hashComments: !0, 394 | multiLineStrings: !0, 395 | tripleQuotedStrings: !0 396 | }), ["cv", "py"]); 397 | k(u({ 398 | keywords: "caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END", 399 | hashComments: !0, 400 | multiLineStrings: !0, 401 | regexLiterals: !0 402 | }), ["perl", "pl", "pm"]); 403 | k(u({ 404 | keywords: J, 405 | hashComments: !0, 406 | multiLineStrings: !0, 407 | regexLiterals: !0 408 | }), ["rb"]); 409 | k(u({ 410 | keywords: w, 411 | cStyleComments: !0, 412 | regexLiterals: !0 413 | }), ["js"]); 414 | k(u({ 415 | keywords: "all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", 416 | hashComments: 3, 417 | cStyleComments: !0, 418 | multilineStrings: !0, 419 | tripleQuotedStrings: !0, 420 | regexLiterals: !0 421 | }), ["coffee"]); 422 | k(x([], [ 423 | ["str", /^[\S\s]+/] 424 | ]), ["regex"]); 425 | window.prettyPrintOne = function(a, m, e) { 426 | var h = document.createElement("PRE"); 427 | h.innerHTML = a; 428 | e && D(h, e); 429 | E({ 430 | g: m, 431 | i: e, 432 | h: h 433 | }); 434 | return h.innerHTML 435 | }; 436 | window.prettyPrint = function(a) { 437 | function m() { 438 | for (var e = window.PR_SHOULD_USE_CONTINUATION ? l.now() + 250 : Infinity; p < h.length && l.now() < e; p++) { 439 | var n = h[p], 440 | k = n.className; 441 | if (k.indexOf("prettyprint") >= 0) { 442 | var k = k.match(g), 443 | f, b; 444 | if (b = !k) { 445 | b = n; 446 | for (var o = void 0, c = b.firstChild; c; c = c.nextSibling) var i = c.nodeType, 447 | o = i === 1 ? o ? b : c : i === 3 ? N.test(c.nodeValue) ? b : o : o; 448 | b = (f = o === b ? void 0 : o) && "CODE" === f.tagName 449 | } 450 | b && (k = f.className.match(g)); 451 | k && (k = k[1]); 452 | b = !1; 453 | for (o = n.parentNode; o; o = o.parentNode) if ((o.tagName === "pre" || o.tagName === "code" || o.tagName === "xmp") && o.className && o.className.indexOf("prettyprint") >= 0) { 454 | b = !0; 455 | break 456 | } 457 | b || ((b = (b = n.className.match(/\blinenums\b(?::(\d+))?/)) ? b[1] && b[1].length ? +b[1] : !0 : !1) && D(n, b), d = { 458 | g: k, 459 | h: n, 460 | i: b 461 | }, E(d)) 462 | } 463 | } 464 | p < h.length ? setTimeout(m, 250) : a && a() 465 | } 466 | for (var e = [document.getElementsByTagName("pre"), document.getElementsByTagName("code"), document.getElementsByTagName("xmp")], h = [], k = 0; k < e.length; ++k) for (var t = 0, s = e[k].length; t < s; ++t) h.push(e[k][t]); 467 | var e = q, 468 | l = Date; 469 | l.now || (l = { 470 | now: function() { 471 | return +new Date 472 | } 473 | }); 474 | var p = 0, 475 | d, g = /\blang(?:uage)?-([\w.]+)(?!\S)/; 476 | m() 477 | }; 478 | window.PR = { 479 | createSimpleLexer: x, 480 | registerLangHandler: k, 481 | sourceDecorator: u, 482 | PR_ATTRIB_NAME: "atn", 483 | PR_ATTRIB_VALUE: "atv", 484 | PR_COMMENT: "com", 485 | PR_DECLARATION: "dec", 486 | PR_KEYWORD: "kwd", 487 | PR_LITERAL: "lit", 488 | PR_NOCODE: "nocode", 489 | PR_PLAIN: "pln", 490 | PR_PUNCTUATION: "pun", 491 | PR_SOURCE: "src", 492 | PR_STRING: "str", 493 | PR_TAG: "tag", 494 | PR_TYPE: "typ" 495 | } 496 | })(); -------------------------------------------------------------------------------- /docs/scripts/sunlight-plugin.doclinks.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sunlight documentation link plugin 3 | * 4 | * This plugin generates hyperlinks to language documentation for certain tokens 5 | * (e.g. links to php.net for functions). 6 | * 7 | * Supported languages: 8 | * - PHP (functions and language constructs) 9 | * - Ruby (functions) 10 | * - Python (functions) 11 | * - Perl (functions) 12 | * - Lua (functions) 13 | * 14 | * Options: 15 | * - enableDocLinks: true/false (default is false) 16 | */ 17 | (function(sunlight, document, undefined){ 18 | if (sunlight === undefined) { 19 | throw "Include sunlight.js before including plugin files"; 20 | } 21 | 22 | var supportedLanguages = { 23 | php: { 24 | "function": function(word) { return "http://php.net/" + word; }, 25 | languageConstruct: function(word) { return "http://php.net/" + word; } 26 | }, 27 | 28 | ruby: { 29 | "function": function(word) { 30 | return "http://www.ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/function.html#" 31 | + word.replace(/!/g, "_bang").replace(/\?/g, "_p"); 32 | } 33 | }, 34 | 35 | python: { 36 | "function": function(word) { 37 | return "http://docs.python.org/py3k/library/functions.html#" + word; 38 | } 39 | }, 40 | 41 | perl: { 42 | "function": function(word) { return "http://perldoc.perl.org/functions/" + word + ".html"; } 43 | }, 44 | 45 | lua: { 46 | "function": function(word) { return "http://www.lua.org/manual/5.1/manual.html#pdf-" + word; } 47 | } 48 | }; 49 | 50 | function createLink(transformUrl) { 51 | return function(context) { 52 | var link = document.createElement("a"); 53 | link.className = context.options.classPrefix + context.tokens[context.index].name; 54 | link.setAttribute("href", transformUrl(context.tokens[context.index].value)); 55 | link.appendChild(context.createTextNode(context.tokens[context.index])); 56 | context.addNode(link); 57 | }; 58 | } 59 | 60 | sunlight.bind("beforeAnalyze", function(context) { 61 | if (!this.options.enableDocLinks) { 62 | return; 63 | } 64 | 65 | context.analyzerContext.getAnalyzer = function() { 66 | var language = supportedLanguages[this.language.name], 67 | analyzer, 68 | tokenName; 69 | 70 | if (!language) { 71 | return; 72 | } 73 | 74 | analyzer = sunlight.util.clone(context.analyzerContext.language.analyzer); 75 | 76 | for (tokenName in language) { 77 | if (!language.hasOwnProperty(tokenName)) { 78 | continue; 79 | } 80 | 81 | analyzer["handle_" + tokenName] = createLink(language[tokenName]); 82 | } 83 | 84 | return analyzer; 85 | }; 86 | 87 | }); 88 | 89 | sunlight.globalOptions.enableDocLinks = false; 90 | 91 | }(this["Sunlight"], document)); -------------------------------------------------------------------------------- /docs/scripts/sunlight-plugin.linenumbers.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sunlight line number/line highlighting plugin 3 | * 4 | * This creates the line number gutter in addition to creating the line highlighting 5 | * overlay (if applicable). It is bundled in sunlight-min.js. 6 | * 7 | * Options: 8 | * - lineNumbers: true/false/"automatic" (default is "automatic") 9 | * - lineNumberStart: (line number to start from, default is 1) 10 | * - lineHighlight: (array of line numbers to highlight) 11 | */ 12 | (function(sunlight, document, undefined){ 13 | if (sunlight === undefined) { 14 | throw "Include sunlight.js before including plugin files"; 15 | } 16 | 17 | function getLineCount(node) { 18 | //browsers don't render the last trailing newline, so we make sure that the line numbers reflect that 19 | //by disregarding the last trailing newline 20 | 21 | //get the last text node 22 | var lastTextNode = function getLastNode(node) { 23 | if (!node.lastChild) { 24 | return null; 25 | } 26 | 27 | if (node.lastChild.nodeType === 3) { 28 | return node.lastChild; 29 | } 30 | 31 | return getLastNode(node.lastChild); 32 | }(node) || { lastChild: "" }; 33 | 34 | return node.innerHTML.replace(/[^\n]/g, "").length - /\n$/.test(lastTextNode.nodeValue); 35 | } 36 | 37 | sunlight.bind("afterHighlightNode", function(context) { 38 | var lineContainer, 39 | lineCount, 40 | lineHighlightOverlay, 41 | currentLineOverlay, 42 | lineHighlightingEnabled, 43 | i, 44 | eol, 45 | link, 46 | name; 47 | 48 | if (!this.options.lineNumbers) { 49 | return; 50 | } 51 | 52 | if (this.options.lineNumbers === "automatic" && sunlight.util.getComputedStyle(context.node, "display") !== "block") { 53 | //if it's not a block level element or the lineNumbers option is not set to "automatic" 54 | return; 55 | } 56 | 57 | lineContainer = document.createElement("pre"); 58 | lineCount = getLineCount(context.node); 59 | 60 | lineHighlightingEnabled = this.options.lineHighlight.length > 0; 61 | if (lineHighlightingEnabled) { 62 | lineHighlightOverlay = document.createElement("div"); 63 | lineHighlightOverlay.className = this.options.classPrefix + "line-highlight-overlay"; 64 | } 65 | 66 | lineContainer.className = this.options.classPrefix + "line-number-margin"; 67 | 68 | eol = document.createTextNode(sunlight.util.eol) 69 | for (i = this.options.lineNumberStart; i <= this.options.lineNumberStart + lineCount; i++) { 70 | link = document.createElement("a"); 71 | name = (context.node.id ? context.node.id : this.options.classPrefix + context.count) + "-line-" + i; 72 | 73 | link.setAttribute("name", name); 74 | link.setAttribute("href", "#" + name); 75 | 76 | link.appendChild(document.createTextNode(i)); 77 | lineContainer.appendChild(link); 78 | lineContainer.appendChild(eol.cloneNode(false)); 79 | 80 | if (lineHighlightingEnabled) { 81 | currentLineOverlay = document.createElement("div"); 82 | if (sunlight.util.contains(this.options.lineHighlight, i)) { 83 | currentLineOverlay.className = this.options.classPrefix + "line-highlight-active"; 84 | } 85 | lineHighlightOverlay.appendChild(currentLineOverlay); 86 | } 87 | } 88 | 89 | context.codeContainer.insertBefore(lineContainer, context.codeContainer.firstChild); 90 | 91 | if (lineHighlightingEnabled) { 92 | context.codeContainer.appendChild(lineHighlightOverlay); 93 | } 94 | 95 | //enable the border on the code container 96 | context.codeContainer.style.borderWidth = "1px"; 97 | context.codeContainer.style.borderStyle = "solid"; 98 | }); 99 | 100 | sunlight.globalOptions.lineNumbers = "automatic"; 101 | sunlight.globalOptions.lineNumberStart = 1; 102 | sunlight.globalOptions.lineHighlight = []; 103 | 104 | }(this["Sunlight"], document)); -------------------------------------------------------------------------------- /docs/scripts/sunlight-plugin.menu.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sunlight menu plugin 3 | * 4 | * This creates the menu in the upper right corner for block-level elements. 5 | * This plugin is not supported for IE6. 6 | * 7 | * Options: 8 | * - showMenu: true/false (default is false) 9 | * - autoCollapse: true/false (default is false) 10 | */ 11 | (function(sunlight, document, undefined){ 12 | if (sunlight === undefined) { 13 | throw "Include sunlight.js before including plugin files"; 14 | } 15 | 16 | //http://dean.edwards.name/weblog/2007/03/sniff/#comment83695 17 | //eval()'d so that it compresses correctly 18 | var ieVersion = eval("0 /*@cc_on+ScriptEngineMajorVersion()@*/"); 19 | 20 | function createLink(href, title, text) { 21 | var link = document.createElement("a"); 22 | link.setAttribute("href", href); 23 | link.setAttribute("title", title); 24 | if (text) { 25 | link.appendChild(document.createTextNode(text)); 26 | } 27 | return link; 28 | } 29 | 30 | function getTextRecursive(node) { 31 | var text = "", 32 | i = 0; 33 | 34 | if (node.nodeType === 3) { 35 | return node.nodeValue; 36 | } 37 | 38 | text = ""; 39 | for (i = 0; i < node.childNodes.length; i++) { 40 | text += getTextRecursive(node.childNodes[i]); 41 | } 42 | 43 | return text; 44 | } 45 | 46 | sunlight.bind("afterHighlightNode", function(context) { 47 | var menu, 48 | sunlightIcon, 49 | ul, 50 | collapse, 51 | mDash, 52 | collapseLink, 53 | viewRaw, 54 | viewRawLink, 55 | about, 56 | aboutLink, 57 | icon; 58 | 59 | if ((ieVersion && ieVersion < 7) || !this.options.showMenu || sunlight.util.getComputedStyle(context.node, "display") !== "block") { 60 | return; 61 | } 62 | 63 | menu = document.createElement("div"); 64 | menu.className = this.options.classPrefix + "menu"; 65 | 66 | sunlightIcon = 67 | "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAJ" + 68 | "cEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41Ljg3O4BdAAAAl0lEQVQ4jWP4" + 69 | "P9n9PyWYgTYGzAr+///Q9P//Ty/HjhfEETDg1oH/YPDgNKbm4wsIuGBO+H84WJJKhhd2dkA0v3tEZhjcPQox4MVN" + 70 | "7P7fUEHAgM112DX++Qkx+PEFMqPxwSmIAQenkWHAvCicAUucAbCAfX2PQCCCEtDGKkz86RXEgL39BAwAKcAFbh/6" + 71 | "/39GIL3yAj0NAAB+LQeDCZ9tvgAAAABJRU5ErkJggg=="; 72 | 73 | ul = document.createElement("ul"); 74 | 75 | collapse = document.createElement("li"); 76 | mDash = String.fromCharCode(0x2014); 77 | collapseLink = createLink("#", "collapse code block", mDash); 78 | 79 | collapseLink.onclick = function() { 80 | var originalHeight = sunlight.util.getComputedStyle(context.codeContainer, "height"), 81 | originalOverflow = sunlight.util.getComputedStyle(context.codeContainer, "overflowY"); 82 | 83 | return function() { 84 | var needsToExpand = sunlight.util.getComputedStyle(context.codeContainer, "height") !== originalHeight; 85 | 86 | this.replaceChild(document.createTextNode(needsToExpand ? mDash : "+"), this.firstChild); 87 | this.setAttribute("title", (needsToExpand ? "collapse" : "expand") + " clode block"); 88 | context.codeContainer.style.height = needsToExpand ? originalHeight : "0px"; 89 | context.codeContainer.style.overflowY = needsToExpand ? originalOverflow : "hidden"; 90 | 91 | return false; 92 | } 93 | }(); 94 | 95 | collapse.appendChild(collapseLink); 96 | 97 | viewRaw = document.createElement("li"); 98 | viewRawLink = createLink("#", "view raw code", "raw"); 99 | viewRawLink.onclick = function() { 100 | var textarea; 101 | return function() { 102 | var rawCode; 103 | 104 | if (textarea) { 105 | textarea.parentNode.removeChild(textarea); 106 | textarea = null; 107 | context.node.style.display = "block"; 108 | this.replaceChild(document.createTextNode("raw"), this.firstChild); 109 | this.setAttribute("title", "view raw code"); 110 | } else { 111 | //hide the codeContainer, flatten all text nodes, create a