Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Gallery Build Tag: gallery-2012.07.18-13-22

  • Loading branch information...
commit e2db97318f2202c22285ab724ee0e8a1db836013 1 parent 47265f6
YUI Builder authored
Showing with 8,960 additions and 350 deletions.
  1. +146 −0 build/gallery-alea/gallery-alea-debug.js
  2. +24 −0 build/gallery-alea/gallery-alea-min.js
  3. +146 −0 build/gallery-alea/gallery-alea.js
  4. +115 −124 build/gallery-anim-morph/gallery-anim-morph-debug.js
  5. +1 −1  build/gallery-anim-morph/gallery-anim-morph-min.js
  6. +115 −124 build/gallery-anim-morph/gallery-anim-morph.js
  7. +3 −3 build/gallery-event-inserted/gallery-event-inserted-debug.js
  8. +1 −1  build/gallery-event-inserted/gallery-event-inserted-min.js
  9. +3 −3 build/gallery-event-inserted/gallery-event-inserted.js
  10. +1 −1  build/gallery-event-selection/gallery-event-selection-debug.js
  11. +1 −1  build/gallery-event-selection/gallery-event-selection-min.js
  12. +1 −1  build/gallery-event-selection/gallery-event-selection.js
  13. +408 −0 build/gallery-l-system/gallery-l-system-debug.js
  14. +1 −0  build/gallery-l-system/gallery-l-system-min.js
  15. +408 −0 build/gallery-l-system/gallery-l-system.js
  16. +1,643 −0 build/gallery-markdown/gallery-markdown-debug.js
  17. +3 −0  build/gallery-markdown/gallery-markdown-min.js
  18. +1,643 −0 build/gallery-markdown/gallery-markdown.js
  19. +136 −0 build/gallery-radial-progress/gallery-radial-progress-debug.js
  20. +1 −0  build/gallery-radial-progress/gallery-radial-progress-min.js
  21. +135 −0 build/gallery-radial-progress/gallery-radial-progress.js
  22. +1 −1  build/gallery-tag-registry/tag-yapp-debug.js
  23. +1 −1  build/gallery-tag-registry/tag-yapp-min.js
  24. +1 −1  build/gallery-tag-registry/tag-yapp.js
  25. +1 −1  build/gallery-tag-registry/tag-yautocomplete-debug.js
  26. +1 −1  build/gallery-tag-registry/tag-yautocomplete-min.js
  27. +1 −1  build/gallery-tag-registry/tag-yautocomplete.js
  28. +1 −1  build/gallery-tag-registry/tag-ybind-debug.js
  29. +1 −1  build/gallery-tag-registry/tag-ybind-min.js
  30. +1 −1  build/gallery-tag-registry/tag-ybind.js
  31. +1 −1  build/gallery-tag-registry/tag-ybutton-debug.js
  32. +1 −1  build/gallery-tag-registry/tag-ybutton-min.js
  33. +1 −1  build/gallery-tag-registry/tag-ybutton.js
  34. +1 −1  build/gallery-tag-registry/tag-ycalendar-debug.js
  35. +1 −1  build/gallery-tag-registry/tag-ycalendar-min.js
  36. +1 −1  build/gallery-tag-registry/tag-ycalendar.js
  37. +1 −1  build/gallery-tag-registry/tag-ydial-debug.js
  38. +1 −1  build/gallery-tag-registry/tag-ydial-min.js
  39. +1 −1  build/gallery-tag-registry/tag-ydial.js
  40. +1 −1  build/gallery-tag-registry/tag-yoverlay-debug.js
  41. +1 −1  build/gallery-tag-registry/tag-yoverlay-min.js
  42. +1 −1  build/gallery-tag-registry/tag-yoverlay.js
  43. +1 −1  build/gallery-tag-registry/tag-ytemplate-debug.js
  44. +1 −1  build/gallery-tag-registry/tag-ytemplate-min.js
  45. +1 −1  build/gallery-tag-registry/tag-ytemplate.js
  46. +38 −33 build/gallery-tag/gallery-tag-debug.js
  47. +1 −1  build/gallery-tag/gallery-tag-min.js
  48. +38 −33 build/gallery-tag/gallery-tag.js
  49. +46 −0 build/gallery-taptotop/assets/gallery-taptotop-core.css
  50. +46 −0 build/gallery-taptotop/assets/skins/sam/gallery-taptotop-skin.css
  51. +1 −0  build/gallery-taptotop/assets/skins/sam/gallery-taptotop.css
  52. +85 −0 build/gallery-taptotop/gallery-taptotop-debug.js
  53. +1 −0  build/gallery-taptotop/gallery-taptotop-min.js
  54. +85 −0 build/gallery-taptotop/gallery-taptotop.js
  55. +810 −0 build/gallery-weighted-list/gallery-weighted-list-debug.js
  56. +1 −0  build/gallery-weighted-list/gallery-weighted-list-min.js
  57. +810 −0 build/gallery-weighted-list/gallery-weighted-list.js
  58. +1 −0  build/gallery-yui-treeview/assets/gallery-yui-treeview-core.css
  59. +51 −0 build/gallery-yui-treeview/assets/skins/sam/gallery-yui-treeview-skin.css
  60. +1 −0  build/gallery-yui-treeview/assets/skins/sam/gallery-yui-treeview.css
  61. BIN  build/gallery-yui-treeview/assets/skins/sam/sprite_tree_view_blue.gif
  62. BIN  build/gallery-yui-treeview/assets/skins/sam/tree_view_icons_blue_01_arrow_beside_folders.gif
  63. +79 −0 build/gallery-yui-treeview/assets/skins/sam/treeview-skin-classic.css
  64. +953 −0 build/gallery-yui-treeview/gallery-yui-treeview-debug.js
  65. +2 −0  build/gallery-yui-treeview/gallery-yui-treeview-min.js
  66. +952 −0 build/gallery-yui-treeview/gallery-yui-treeview.js
View
146 build/gallery-alea/gallery-alea-debug.js
@@ -0,0 +1,146 @@
+YUI.add('gallery-alea', function(Y) {
+
+/*!
+ * based on Alea.js and Mash.js. http://baagoe.com/en/RandomMusings/javascript/
+ * Copyright (C) 2010 by Johannes Baagøe <baagoe@baagoe.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/**
+ * Y.Alea is a better pseudorandom number generator than Math.random.
+ *
+ * based on Alea.js and Mash.js. http://baagoe.com/en/RandomMusings/javascript/
+ * Copyright (C) 2010 by Johannes Baagøe <baagoe@baagoe.org>
+ * @module gallery-alea
+ */
+(function (Y) {
+ 'use strict';
+
+ var _Array = Y.Array,
+
+ _each = _Array.each,
+ _mash = function () {
+ var n = 0xefc8249d;
+
+ return function (data) {
+ data = data.toString();
+
+ var h,
+ i = 0,
+ length = data.length;
+
+ for (; i < length; i += 1) {
+ n += data.charCodeAt(i);
+ h = 0.02519603282416938 * n;
+ n = h >>> 0;
+ h -= n;
+ h *= n;
+ n = h >>> 0;
+ h -= n;
+ n += h * 0x100000000; // 2^32
+ }
+
+ return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
+ };
+ },
+ _now = Y.Lang.now,
+
+ /**
+ * @class Alea
+ * @constructor
+ * @param [seedValues*] Optional. Any number of seed values. If left
+ * undefined, Y.Lang.now() is used.
+ */
+ _class = function () {
+ var args = _Array(arguments),
+ c = 1,
+ mash = _mash(),
+ s0 = mash(' '),
+ s1 = mash(' '),
+ s2 = mash(' ');
+
+ if (!args.length) {
+ args.push(_now());
+ }
+
+ _each(args, function (arg) {
+ s0 -= mash(arg);
+
+ if (s0 < 0) {
+ s0 += 1;
+ }
+
+ s1 -= mash(arg);
+
+ if (s1 < 0) {
+ s1 += 1;
+ }
+
+ s2 -= mash(arg);
+
+ if (s2 < 0) {
+ s2 += 1;
+ }
+ });
+
+ /**
+ * Generates a random number that is greater than or equal to zero
+ * and less than one. The number will be a 32-bit fraction.
+ * @method random
+ * @return Number
+ */
+ this.random = function () {
+ var t = 2091639 * s0 + c * 2.3283064365386963e-10; // 2^-32
+
+ c = t | 0;
+ s0 = s1;
+ s1 = s2;
+ s2 = t - c;
+
+ return s2;
+ };
+ };
+
+ _class.prototype = {
+ /**
+ * Generates a random number that is greater than or equal to zero
+ * and less than one. The number will be a 53-bit fraction.
+ * @method fract53
+ * @return Number
+ */
+ fract53: function () {
+ var random = this.random;
+ return random() + (random() * 0x200000 | 0) * 1.1102230246251565e-16; // 2^-53
+ },
+ /**
+ * Generates a random 32-bit unsigned integer.
+ * @method uint32
+ * @return Number
+ */
+ uint32: function () {
+ return this.random() * 0x100000000; // 2^32
+ }
+ };
+
+ Y.Alea = _class;
+}(Y));
+
+
+}, 'gallery-2012.07.18-13-22' ,{requires:['yui-base'], skinnable:false});
View
24 build/gallery-alea/gallery-alea-min.js
@@ -0,0 +1,24 @@
+YUI.add("gallery-alea",function(a){
+/*!
+ * based on Alea.js and Mash.js. http://baagoe.com/en/RandomMusings/javascript/
+ * Copyright (C) 2010 by Johannes Baagøe <baagoe@baagoe.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+(function(g){var b=g.Array,f=b.each,d=function(){var h=4022871197;return function(m){m=m.toString();var k,j=0,l=m.length;for(;j<l;j+=1){h+=m.charCodeAt(j);k=0.02519603282416938*h;h=k>>>0;k-=h;k*=h;h=k>>>0;k-=h;h+=k*4294967296;}return(h>>>0)*2.3283064365386963e-10;};},e=g.Lang.now,c=function(){var i=b(arguments),m=1,k=d(),l=k(" "),j=k(" "),h=k(" ");if(!i.length){i.push(e());}f(i,function(n){l-=k(n);if(l<0){l+=1;}j-=k(n);if(j<0){j+=1;}h-=k(n);if(h<0){h+=1;}});this.random=function(){var n=2091639*l+m*2.3283064365386963e-10;m=n|0;l=j;j=h;h=n-m;return h;};};c.prototype={fract53:function(){var h=this.random;return h()+(h()*2097152|0)*1.1102230246251565e-16;},uint32:function(){return this.random()*4294967296;}};g.Alea=c;}(a));},"gallery-2012.07.18-13-22",{requires:["yui-base"],skinnable:false});
View
146 build/gallery-alea/gallery-alea.js
@@ -0,0 +1,146 @@
+YUI.add('gallery-alea', function(Y) {
+
+/*!
+ * based on Alea.js and Mash.js. http://baagoe.com/en/RandomMusings/javascript/
+ * Copyright (C) 2010 by Johannes Baagøe <baagoe@baagoe.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/**
+ * Y.Alea is a better pseudorandom number generator than Math.random.
+ *
+ * based on Alea.js and Mash.js. http://baagoe.com/en/RandomMusings/javascript/
+ * Copyright (C) 2010 by Johannes Baagøe <baagoe@baagoe.org>
+ * @module gallery-alea
+ */
+(function (Y) {
+ 'use strict';
+
+ var _Array = Y.Array,
+
+ _each = _Array.each,
+ _mash = function () {
+ var n = 0xefc8249d;
+
+ return function (data) {
+ data = data.toString();
+
+ var h,
+ i = 0,
+ length = data.length;
+
+ for (; i < length; i += 1) {
+ n += data.charCodeAt(i);
+ h = 0.02519603282416938 * n;
+ n = h >>> 0;
+ h -= n;
+ h *= n;
+ n = h >>> 0;
+ h -= n;
+ n += h * 0x100000000; // 2^32
+ }
+
+ return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
+ };
+ },
+ _now = Y.Lang.now,
+
+ /**
+ * @class Alea
+ * @constructor
+ * @param [seedValues*] Optional. Any number of seed values. If left
+ * undefined, Y.Lang.now() is used.
+ */
+ _class = function () {
+ var args = _Array(arguments),
+ c = 1,
+ mash = _mash(),
+ s0 = mash(' '),
+ s1 = mash(' '),
+ s2 = mash(' ');
+
+ if (!args.length) {
+ args.push(_now());
+ }
+
+ _each(args, function (arg) {
+ s0 -= mash(arg);
+
+ if (s0 < 0) {
+ s0 += 1;
+ }
+
+ s1 -= mash(arg);
+
+ if (s1 < 0) {
+ s1 += 1;
+ }
+
+ s2 -= mash(arg);
+
+ if (s2 < 0) {
+ s2 += 1;
+ }
+ });
+
+ /**
+ * Generates a random number that is greater than or equal to zero
+ * and less than one. The number will be a 32-bit fraction.
+ * @method random
+ * @return Number
+ */
+ this.random = function () {
+ var t = 2091639 * s0 + c * 2.3283064365386963e-10; // 2^-32
+
+ c = t | 0;
+ s0 = s1;
+ s1 = s2;
+ s2 = t - c;
+
+ return s2;
+ };
+ };
+
+ _class.prototype = {
+ /**
+ * Generates a random number that is greater than or equal to zero
+ * and less than one. The number will be a 53-bit fraction.
+ * @method fract53
+ * @return Number
+ */
+ fract53: function () {
+ var random = this.random;
+ return random() + (random() * 0x200000 | 0) * 1.1102230246251565e-16; // 2^-53
+ },
+ /**
+ * Generates a random 32-bit unsigned integer.
+ * @method uint32
+ * @return Number
+ */
+ uint32: function () {
+ return this.random() * 0x100000000; // 2^32
+ }
+ };
+
+ Y.Alea = _class;
+}(Y));
+
+
+}, 'gallery-2012.07.18-13-22' ,{requires:['yui-base'], skinnable:false});
View
239 build/gallery-anim-morph/gallery-anim-morph-debug.js
@@ -1,148 +1,139 @@
YUI.add('gallery-anim-morph', function(Y) {
-/* Copyright 2012 Canonical Ltd. This software is licensed under the
- * GNU Affero General Public License version 3 (see the file LICENSE).
+var module = Y.namespace('gallery.anim.morph');
+
+/**
+ * Morph animation class to swap between two nodes.
*
- * Widget to fade and resize between two DOM nodes.
+ * @class Morph
+ * @module gallery.anim.morph
+ * @extends Widget
+ * @constructor
*
*/
-YUI.add('gallery-anim-morph', function(Y) {
- var module = Y.namespace('gallery.anim.morph');
+module.Morph = Y.Base.create('gallery-anim-morph', Y.Widget, [], {
+
+ _animate: true,
/**
- * Morph animation class to swap between two nodes.
+ * Perform the animated version of the Morph.
*
- * @class Morph
- * @module gallery.anim.morph
- * @extends Widget
- * @constructor
+ * @method _perform_anim_morph
+ * @param {Event} ev
+ * @param {Node} src
+ * @param {Node} target
+ * @private
*
*/
- module.Morph = Y.Base.create('gallery-anim-morph', Y.Widget, [], {
-
- _animate: true,
+ _perform_anim_morph: function (ev, src, target) {
+ var that = this,
+ src_height = src.getComputedStyle('height').replace('px', ''),
+ target_height = target.getComputedStyle('height');
+
+ target.addClass('hidden');
+ src.setStyle('opacity', 0);
+ src.removeClass('hidden');
+ src.setStyle('height', target_height);
+
+ var fade_in = new Y.Anim({
+ node: src,
+ to: {opacity: 1},
+ duration: 1,
+ easing: 'easeIn'
+ });
- /**
- * Perform the animated version of the Morph.
- *
- * @method _perform_anim_morph
- * @param {Event} ev
- * @param {Node} src
- * @param {Node} target
- * @private
- *
- */
- _perform_anim_morph: function (ev, src, target) {
- var that = this,
- src_height = src.getComputedStyle('height').replace('px', ''),
- target_height = target.getComputedStyle('height');
-
- target.addClass('hidden');
- src.setStyle('opacity', 0);
- src.removeClass('hidden');
- src.setStyle('height', target_height);
-
- var fade_in = new Y.Anim({
- node: src,
- to: {opacity: 1},
- duration: 1,
- easing: 'easeIn'
- });
-
- var resize = new Y.Anim({
- node: src,
- to: {height: src_height},
- duration: 0.5,
- easing: 'easeOut'
- });
-
- resize.on('end', function () {
- src.setStyle('height', 'auto');
- that.fire('morphed');
+ var resize = new Y.Anim({
+ node: src,
+ to: {height: src_height},
+ duration: 0.5,
+ easing: 'easeOut'
});
- fade_in.run();
- resize.run();
- },
+ resize.on('end', function () {
+ src.setStyle('height', 'auto');
+ that.fire('morphed');
+ });
- /**
- * Pass an optional animate boolean flag to skip animations. Useful
- * for initial states/testing.
- *
- * @method initializer
- * @param {Object} cfg
- *
- */
- initializer: function(cfg) {
- if (Y.Lang.isValue(cfg.animate)) {
- this._animate = cfg.animate;
- } else {
- this._animate = true;
- }
- },
+ fade_in.run();
+ resize.run();
+ },
- /**
- * Perform the morph animation between the nodes.
- *
- * @method morph
- * @param {Bool} reverse the animation back.
- *
- */
- morph: function(reverse) {
- var srcNode = this.get(reverse ? 'targetNode' : 'srcNode');
- var targetNode = this.get(reverse ? 'srcNode' : 'targetNode');
-
- if (this._animate) {
- var that = this,
- fade_out = new Y.Anim({
- node: targetNode,
- to: {opacity: 0},
- duration: 0.2,
- easing: 'easeOut'
- });
-
- fade_out.on('end', this._perform_anim_morph, this, targetNode, srcNode);
- fade_out.run();
-
- } else {
- targetNode.addClass('hidden');
- srcNode.removeClass('hidden');
- srcNode.setStyle('height', 'auto');
- this.fire('morphed');
- }
- },
+ /**
+ * Pass an optional animate boolean flag to skip animations. Useful
+ * for initial states/testing.
+ *
+ * @method initializer
+ * @param {Object} cfg
+ *
+ */
+ initializer: function(cfg) {
+ if (Y.Lang.isValue(cfg.animate)) {
+ this._animate = cfg.animate;
+ } else {
+ this._animate = true;
+ }
+ },
+
+ /**
+ * Perform the morph animation between the nodes.
+ *
+ * @method morph
+ * @param {Bool} reverse the animation back.
+ *
+ */
+ morph: function(reverse) {
+ var srcNode = this.get(reverse ? 'targetNode' : 'srcNode');
+ var targetNode = this.get(reverse ? 'srcNode' : 'targetNode');
+
+ if (this._animate) {
+ var that = this,
+ fade_out = new Y.Anim({
+ node: targetNode,
+ to: {opacity: 0},
+ duration: 0.2,
+ easing: 'easeOut'
+ });
+
+ fade_out.on('end', this._perform_anim_morph, this, targetNode, srcNode);
+ fade_out.run();
+
+ } else {
+ targetNode.addClass('hidden');
+ srcNode.removeClass('hidden');
+ srcNode.setStyle('height', 'auto');
+ this.fire('morphed');
+ }
+ },
+ /**
+ * Reverse the animation effect.
+ *
+ * Shortcut for morph(true)
+ *
+ * @method reverse
+ *
+ */
+ reverse: function () {
+ this.morph(true);
+ }
+},{
+ ATTRS: {
/**
- * Reverse the animation effect.
- *
- * Shortcut for morph(true)
+ * The DOM node to be morphed from.
*
- * @method reverse
+ * @attribute targetNode
+ * @default null
+ * @type String|Node
*
*/
- reverse: function () {
- this.morph(true);
- }
- },{
- ATTRS: {
- /**
- * The DOM node to be morphed from.
- *
- * @attribute targetNode
- * @default null
- * @type String|Node
- *
- */
- targetNode: {
- value: null,
- setter: function(val) {
- return Y.one(val);
- }
+ targetNode: {
+ value: null,
+ setter: function(val) {
+ return Y.one(val);
}
}
- });
-
-}, '0.1', {'requires': ['anim', 'base', 'node', 'widget']});
+ }
+});
-}, 'gallery-2012.07.11-21-38' ,{requires:['anim', 'base', 'node', 'widget'], skinnable:false});
+}, 'gallery-2012.07.18-13-22' ,{requires:['anim', 'base', 'node', 'widget'], skinnable:false});
View
2  build/gallery-anim-morph/gallery-anim-morph-min.js
@@ -1 +1 @@
-YUI.add("gallery-anim-morph",function(a){YUI.add("gallery-anim-morph",function(c){var b=c.namespace("gallery.anim.morph");b.Morph=c.Base.create("gallery-anim-morph",c.Widget,[],{_animate:true,_perform_anim_morph:function(i,k,j){var h=this,g=k.getComputedStyle("height").replace("px",""),f=j.getComputedStyle("height");j.addClass("hidden");k.setStyle("opacity",0);k.removeClass("hidden");k.setStyle("height",f);var d=new c.Anim({node:k,to:{opacity:1},duration:1,easing:"easeIn"});var e=new c.Anim({node:k,to:{height:g},duration:0.5,easing:"easeOut"});e.on("end",function(){k.setStyle("height","auto");h.fire("morphed");});d.run();e.run();},initializer:function(d){if(c.Lang.isValue(d.animate)){this._animate=d.animate;}else{this._animate=true;}},morph:function(e){var h=this.get(e?"targetNode":"srcNode");var g=this.get(e?"srcNode":"targetNode");if(this._animate){var f=this,d=new c.Anim({node:g,to:{opacity:0},duration:0.2,easing:"easeOut"});d.on("end",this._perform_anim_morph,this,g,h);d.run();}else{g.addClass("hidden");h.removeClass("hidden");h.setStyle("height","auto");this.fire("morphed");}},reverse:function(){this.morph(true);}},{ATTRS:{targetNode:{value:null,setter:function(d){return c.one(d);}}}});},"0.1",{"requires":["anim","base","node","widget"]});},"gallery-2012.07.11-21-38",{requires:["anim","base","node","widget"],skinnable:false});
+YUI.add("gallery-anim-morph",function(b){var a=b.namespace("gallery.anim.morph");a.Morph=b.Base.create("gallery-anim-morph",b.Widget,[],{_animate:true,_perform_anim_morph:function(h,j,i){var g=this,f=j.getComputedStyle("height").replace("px",""),e=i.getComputedStyle("height");i.addClass("hidden");j.setStyle("opacity",0);j.removeClass("hidden");j.setStyle("height",e);var c=new b.Anim({node:j,to:{opacity:1},duration:1,easing:"easeIn"});var d=new b.Anim({node:j,to:{height:f},duration:0.5,easing:"easeOut"});d.on("end",function(){j.setStyle("height","auto");g.fire("morphed");});c.run();d.run();},initializer:function(c){if(b.Lang.isValue(c.animate)){this._animate=c.animate;}else{this._animate=true;}},morph:function(d){var g=this.get(d?"targetNode":"srcNode");var f=this.get(d?"srcNode":"targetNode");if(this._animate){var e=this,c=new b.Anim({node:f,to:{opacity:0},duration:0.2,easing:"easeOut"});c.on("end",this._perform_anim_morph,this,f,g);c.run();}else{f.addClass("hidden");g.removeClass("hidden");g.setStyle("height","auto");this.fire("morphed");}},reverse:function(){this.morph(true);}},{ATTRS:{targetNode:{value:null,setter:function(c){return b.one(c);}}}});},"gallery-2012.07.18-13-22",{requires:["anim","base","node","widget"],skinnable:false});
View
239 build/gallery-anim-morph/gallery-anim-morph.js
@@ -1,148 +1,139 @@
YUI.add('gallery-anim-morph', function(Y) {
-/* Copyright 2012 Canonical Ltd. This software is licensed under the
- * GNU Affero General Public License version 3 (see the file LICENSE).
+var module = Y.namespace('gallery.anim.morph');
+
+/**
+ * Morph animation class to swap between two nodes.
*
- * Widget to fade and resize between two DOM nodes.
+ * @class Morph
+ * @module gallery.anim.morph
+ * @extends Widget
+ * @constructor
*
*/
-YUI.add('gallery-anim-morph', function(Y) {
- var module = Y.namespace('gallery.anim.morph');
+module.Morph = Y.Base.create('gallery-anim-morph', Y.Widget, [], {
+
+ _animate: true,
/**
- * Morph animation class to swap between two nodes.
+ * Perform the animated version of the Morph.
*
- * @class Morph
- * @module gallery.anim.morph
- * @extends Widget
- * @constructor
+ * @method _perform_anim_morph
+ * @param {Event} ev
+ * @param {Node} src
+ * @param {Node} target
+ * @private
*
*/
- module.Morph = Y.Base.create('gallery-anim-morph', Y.Widget, [], {
-
- _animate: true,
+ _perform_anim_morph: function (ev, src, target) {
+ var that = this,
+ src_height = src.getComputedStyle('height').replace('px', ''),
+ target_height = target.getComputedStyle('height');
+
+ target.addClass('hidden');
+ src.setStyle('opacity', 0);
+ src.removeClass('hidden');
+ src.setStyle('height', target_height);
+
+ var fade_in = new Y.Anim({
+ node: src,
+ to: {opacity: 1},
+ duration: 1,
+ easing: 'easeIn'
+ });
- /**
- * Perform the animated version of the Morph.
- *
- * @method _perform_anim_morph
- * @param {Event} ev
- * @param {Node} src
- * @param {Node} target
- * @private
- *
- */
- _perform_anim_morph: function (ev, src, target) {
- var that = this,
- src_height = src.getComputedStyle('height').replace('px', ''),
- target_height = target.getComputedStyle('height');
-
- target.addClass('hidden');
- src.setStyle('opacity', 0);
- src.removeClass('hidden');
- src.setStyle('height', target_height);
-
- var fade_in = new Y.Anim({
- node: src,
- to: {opacity: 1},
- duration: 1,
- easing: 'easeIn'
- });
-
- var resize = new Y.Anim({
- node: src,
- to: {height: src_height},
- duration: 0.5,
- easing: 'easeOut'
- });
-
- resize.on('end', function () {
- src.setStyle('height', 'auto');
- that.fire('morphed');
+ var resize = new Y.Anim({
+ node: src,
+ to: {height: src_height},
+ duration: 0.5,
+ easing: 'easeOut'
});
- fade_in.run();
- resize.run();
- },
+ resize.on('end', function () {
+ src.setStyle('height', 'auto');
+ that.fire('morphed');
+ });
- /**
- * Pass an optional animate boolean flag to skip animations. Useful
- * for initial states/testing.
- *
- * @method initializer
- * @param {Object} cfg
- *
- */
- initializer: function(cfg) {
- if (Y.Lang.isValue(cfg.animate)) {
- this._animate = cfg.animate;
- } else {
- this._animate = true;
- }
- },
+ fade_in.run();
+ resize.run();
+ },
- /**
- * Perform the morph animation between the nodes.
- *
- * @method morph
- * @param {Bool} reverse the animation back.
- *
- */
- morph: function(reverse) {
- var srcNode = this.get(reverse ? 'targetNode' : 'srcNode');
- var targetNode = this.get(reverse ? 'srcNode' : 'targetNode');
-
- if (this._animate) {
- var that = this,
- fade_out = new Y.Anim({
- node: targetNode,
- to: {opacity: 0},
- duration: 0.2,
- easing: 'easeOut'
- });
-
- fade_out.on('end', this._perform_anim_morph, this, targetNode, srcNode);
- fade_out.run();
-
- } else {
- targetNode.addClass('hidden');
- srcNode.removeClass('hidden');
- srcNode.setStyle('height', 'auto');
- this.fire('morphed');
- }
- },
+ /**
+ * Pass an optional animate boolean flag to skip animations. Useful
+ * for initial states/testing.
+ *
+ * @method initializer
+ * @param {Object} cfg
+ *
+ */
+ initializer: function(cfg) {
+ if (Y.Lang.isValue(cfg.animate)) {
+ this._animate = cfg.animate;
+ } else {
+ this._animate = true;
+ }
+ },
+
+ /**
+ * Perform the morph animation between the nodes.
+ *
+ * @method morph
+ * @param {Bool} reverse the animation back.
+ *
+ */
+ morph: function(reverse) {
+ var srcNode = this.get(reverse ? 'targetNode' : 'srcNode');
+ var targetNode = this.get(reverse ? 'srcNode' : 'targetNode');
+
+ if (this._animate) {
+ var that = this,
+ fade_out = new Y.Anim({
+ node: targetNode,
+ to: {opacity: 0},
+ duration: 0.2,
+ easing: 'easeOut'
+ });
+
+ fade_out.on('end', this._perform_anim_morph, this, targetNode, srcNode);
+ fade_out.run();
+
+ } else {
+ targetNode.addClass('hidden');
+ srcNode.removeClass('hidden');
+ srcNode.setStyle('height', 'auto');
+ this.fire('morphed');
+ }
+ },
+ /**
+ * Reverse the animation effect.
+ *
+ * Shortcut for morph(true)
+ *
+ * @method reverse
+ *
+ */
+ reverse: function () {
+ this.morph(true);
+ }
+},{
+ ATTRS: {
/**
- * Reverse the animation effect.
- *
- * Shortcut for morph(true)
+ * The DOM node to be morphed from.
*
- * @method reverse
+ * @attribute targetNode
+ * @default null
+ * @type String|Node
*
*/
- reverse: function () {
- this.morph(true);
- }
- },{
- ATTRS: {
- /**
- * The DOM node to be morphed from.
- *
- * @attribute targetNode
- * @default null
- * @type String|Node
- *
- */
- targetNode: {
- value: null,
- setter: function(val) {
- return Y.one(val);
- }
+ targetNode: {
+ value: null,
+ setter: function(val) {
+ return Y.one(val);
}
}
- });
-
-}, '0.1', {'requires': ['anim', 'base', 'node', 'widget']});
+ }
+});
-}, 'gallery-2012.07.11-21-38' ,{requires:['anim', 'base', 'node', 'widget'], skinnable:false});
+}, 'gallery-2012.07.18-13-22' ,{requires:['anim', 'base', 'node', 'widget'], skinnable:false});
View
6 build/gallery-event-inserted/gallery-event-inserted-debug.js
@@ -45,7 +45,7 @@ Inserted = {
sub._handle = node[method](Inserted.ANIMATION_START, Y.bind(function(e) {
if (e._event.animationName === Inserted.NAME) {
- notifier.fire({target: e.target});
+ notifier.fire({target: e.target, selector: sub._extra});
}
}, this), filter);
@@ -94,7 +94,7 @@ DOMInserted = {
// Delegates don't seem to work for DOMNodeInserted :(
sub._handle = node[method]('DOMNodeInserted', Y.bind(function(e) {
if (Y.Selector.test(e.target.getDOMNode(), sub._extra, doc_node.getDOMNode())) {
- notifier.fire({target: e.target});
+ notifier.fire({target: e.target, selector: sub._extra});
}
}, this), filter);
},
@@ -116,4 +116,4 @@ DOMInserted = {
Y.Event.define('inserted', VENDOR ? Inserted : DOMInserted);
-}, 'gallery-2012.07.05-20-01' ,{requires:['event', 'node'], skinnable:false});
+}, 'gallery-2012.07.18-13-22' ,{requires:['event', 'node'], skinnable:false});
View
2  build/gallery-event-inserted/gallery-event-inserted-min.js
@@ -1 +1 @@
-YUI.add("gallery-event-inserted",function(d){var c=["","WebKit","Moz","O","MS"].filter(function(e){return d.config.win[e+"CSSKeyframesRule"];})[0],b,a;b={NAME:"InsertedNode",PREFIX:c?"-"+c.toLowerCase()+"-":c,ANIMATION_START_VENDORS:{WebKit:"webkitAnimationStart",O:"oAnimationStart"},ANIMATION_START:"animationstart",STYLESHEET:null,_init:function(){b.ANIMATION_START=b.ANIMATION_START_VENDORS[c]||b.ANIMATION_START;d.Node.DOM_EVENTS[b.ANIMATION_START]=1;b.STYLESHEET=d.Node.create('<style type="text/css">@'+b.PREFIX+"keyframes "+b.NAME+" {"+"from {clip: rect(1px, auto, auto, auto);} to {clip: rect(0px, auto, auto, auto);}"+"}</style>");d.one("head").append(b.STYLESHEET);},processArgs:function(f,e){return f.splice(2,1)[0];},on:function(h,f,g,e){var j=e?"delegate":"on",i=f._extra+"{"+b.PREFIX+"animation-duration: 0.0001s; "+b.PREFIX+"animation-name: "+b.NAME+" !important;}";f._handle=h[j](b.ANIMATION_START,d.bind(function(k){if(k._event.animationName===b.NAME){g.fire({target:k.target});}},this),e);b.STYLESHEET.get("sheet").insertRule(i,0);},delegate:function(){this.on.apply(this,arguments);},detach:function(g,e,f){e._handle.detach();},detachDelegate:function(){this.detach.apply(this,arguments);}};a={SELECTORS:{},_init:function(){d.Node.DOM_EVENTS.DOMNodeInserted=1;},processArgs:function(f,e){return f.splice(2,1)[0];},on:function(h,f,g,e){var j=e?"delegate":"on",i=(h.get("document")||h);if(!a.SELECTORS[f._extra]){a.SELECTORS[f._extra]=true;setTimeout(function(){i.all(f._extra).each(function(k){g.fire({target:k});});},0);}f._handle=h[j]("DOMNodeInserted",d.bind(function(k){if(d.Selector.test(k.target.getDOMNode(),f._extra,i.getDOMNode())){g.fire({target:k.target});}},this),e);},delegate:function(){this.on.apply(this,arguments);},detach:function(g,e,f){e._handle.detach();},detachDelegate:function(){this.detach.apply(this,arguments);}};d.Event.define("inserted",c?b:a);},"gallery-2012.07.05-20-01",{requires:["event","node"],skinnable:false});
+YUI.add("gallery-event-inserted",function(d){var c=["","WebKit","Moz","O","MS"].filter(function(e){return d.config.win[e+"CSSKeyframesRule"];})[0],b,a;b={NAME:"InsertedNode",PREFIX:c?"-"+c.toLowerCase()+"-":c,ANIMATION_START_VENDORS:{WebKit:"webkitAnimationStart",O:"oAnimationStart"},ANIMATION_START:"animationstart",STYLESHEET:null,_init:function(){b.ANIMATION_START=b.ANIMATION_START_VENDORS[c]||b.ANIMATION_START;d.Node.DOM_EVENTS[b.ANIMATION_START]=1;b.STYLESHEET=d.Node.create('<style type="text/css">@'+b.PREFIX+"keyframes "+b.NAME+" {"+"from {clip: rect(1px, auto, auto, auto);} to {clip: rect(0px, auto, auto, auto);}"+"}</style>");d.one("head").append(b.STYLESHEET);},processArgs:function(f,e){return f.splice(2,1)[0];},on:function(h,f,g,e){var j=e?"delegate":"on",i=f._extra+"{"+b.PREFIX+"animation-duration: 0.0001s; "+b.PREFIX+"animation-name: "+b.NAME+" !important;}";f._handle=h[j](b.ANIMATION_START,d.bind(function(k){if(k._event.animationName===b.NAME){g.fire({target:k.target,selector:f._extra});}},this),e);b.STYLESHEET.get("sheet").insertRule(i,0);},delegate:function(){this.on.apply(this,arguments);},detach:function(g,e,f){e._handle.detach();},detachDelegate:function(){this.detach.apply(this,arguments);}};a={SELECTORS:{},_init:function(){d.Node.DOM_EVENTS.DOMNodeInserted=1;},processArgs:function(f,e){return f.splice(2,1)[0];},on:function(h,f,g,e){var j=e?"delegate":"on",i=(h.get("document")||h);if(!a.SELECTORS[f._extra]){a.SELECTORS[f._extra]=true;setTimeout(function(){i.all(f._extra).each(function(k){g.fire({target:k});});},0);}f._handle=h[j]("DOMNodeInserted",d.bind(function(k){if(d.Selector.test(k.target.getDOMNode(),f._extra,i.getDOMNode())){g.fire({target:k.target,selector:f._extra});}},this),e);},delegate:function(){this.on.apply(this,arguments);},detach:function(g,e,f){e._handle.detach();},detachDelegate:function(){this.detach.apply(this,arguments);}};d.Event.define("inserted",c?b:a);},"gallery-2012.07.18-13-22",{requires:["event","node"],skinnable:false});
View
6 build/gallery-event-inserted/gallery-event-inserted.js
@@ -45,7 +45,7 @@ Inserted = {
sub._handle = node[method](Inserted.ANIMATION_START, Y.bind(function(e) {
if (e._event.animationName === Inserted.NAME) {
- notifier.fire({target: e.target});
+ notifier.fire({target: e.target, selector: sub._extra});
}
}, this), filter);
@@ -94,7 +94,7 @@ DOMInserted = {
// Delegates don't seem to work for DOMNodeInserted :(
sub._handle = node[method]('DOMNodeInserted', Y.bind(function(e) {
if (Y.Selector.test(e.target.getDOMNode(), sub._extra, doc_node.getDOMNode())) {
- notifier.fire({target: e.target});
+ notifier.fire({target: e.target, selector: sub._extra});
}
}, this), filter);
},
@@ -116,4 +116,4 @@ DOMInserted = {
Y.Event.define('inserted', VENDOR ? Inserted : DOMInserted);
-}, 'gallery-2012.07.05-20-01' ,{requires:['event', 'node'], skinnable:false});
+}, 'gallery-2012.07.18-13-22' ,{requires:['event', 'node'], skinnable:false});
View
2  build/gallery-event-selection/gallery-event-selection-debug.js
@@ -131,4 +131,4 @@ Y.Event.define('selectionchange', {
});
-}, 'gallery-2012.07.05-20-01' ,{requires:['event-move'], skinnable:false});
+}, 'gallery-2012.07.18-13-22' ,{requires:['event-move'], skinnable:false});
View
2  build/gallery-event-selection/gallery-event-selection-min.js
@@ -1 +1 @@
-YUI.add("gallery-event-selection",function(d){var c=d.UA.ios?400:0,b=300;function a(){if(d.config.win.getSelection){return d.config.win.getSelection().toString();}else{if(d.config.doc.selection){return d.config.doc.selection.createRange().text;}}return"";}d.Event.define("selection",{on:function(h,f,g,e){var i=e?"delegate":"on";f._notifier=g;f._handle=new d.EventHandle([h[i]("gesturemovestart",function(j){},e),h[i]("gesturemoveend",d.bind(function(j){f._x=j.pageX;f._y=j.pageY;d.later(c,this,this._checkSelection,f);},this),e)]);},delegate:function(){this.on.apply(this,arguments);},detach:function(g,e,f){e._handle.detach();},detachDelegate:function(){this.detach.apply(this,arguments);},_checkSelection:function(f){var e=a();if(e!==""){f._notifier.fire({selection:e,pageX:f._x,pageY:f._y});}}});d.Event.define("selectionchange",{_poll:null,on:function(h,f,g,e){var i=e?"delegate":"on";f._selection="";f._notifier=g;f._handle=new d.EventHandle([d.on("gesturemovestart",d.bind(function(j){this._unpoll();if(f._selection){d.later(0,this,this._checkSelectionChange,f);}},this)),h[i]("gesturemovestart",function(j){},e),h[i]("gesturemoveend",d.bind(function(j){f._x=j.pageX;f._y=j.pageY;d.later(c,this,this._checkSelection,f);},this),e)]);},delegate:function(){this.on.apply(this,arguments);},detach:function(g,e,f){this._unpoll();e._handle.detach();},detachDelegate:function(){this.detach.apply(this,arguments);},_checkSelection:function(e){this._unpoll();this._checkSelectionChange(e);this._poll=d.later(b,this,this._checkSelectionChange,e,true);},_checkSelectionChange:function(f){var e=a();if(e!==f._selection){f._selection=e;f._notifier.fire({selection:f._selection,pageX:f._x,pageY:f._y});}},_unpoll:function(){if(this._poll){this._poll.cancel();this._poll=null;}}});},"gallery-2012.07.05-20-01",{requires:["event-move"],skinnable:false});
+YUI.add("gallery-event-selection",function(d){var c=d.UA.ios?400:0,b=300;function a(){if(d.config.win.getSelection){return d.config.win.getSelection().toString();}else{if(d.config.doc.selection){return d.config.doc.selection.createRange().text;}}return"";}d.Event.define("selection",{on:function(h,f,g,e){var i=e?"delegate":"on";f._notifier=g;f._handle=new d.EventHandle([h[i]("gesturemovestart",function(j){},e),h[i]("gesturemoveend",d.bind(function(j){f._x=j.pageX;f._y=j.pageY;d.later(c,this,this._checkSelection,f);},this),e)]);},delegate:function(){this.on.apply(this,arguments);},detach:function(g,e,f){e._handle.detach();},detachDelegate:function(){this.detach.apply(this,arguments);},_checkSelection:function(f){var e=a();if(e!==""){f._notifier.fire({selection:e,pageX:f._x,pageY:f._y});}}});d.Event.define("selectionchange",{_poll:null,on:function(h,f,g,e){var i=e?"delegate":"on";f._selection="";f._notifier=g;f._handle=new d.EventHandle([d.on("gesturemovestart",d.bind(function(j){this._unpoll();if(f._selection){d.later(0,this,this._checkSelectionChange,f);}},this)),h[i]("gesturemovestart",function(j){},e),h[i]("gesturemoveend",d.bind(function(j){f._x=j.pageX;f._y=j.pageY;d.later(c,this,this._checkSelection,f);},this),e)]);},delegate:function(){this.on.apply(this,arguments);},detach:function(g,e,f){this._unpoll();e._handle.detach();},detachDelegate:function(){this.detach.apply(this,arguments);},_checkSelection:function(e){this._unpoll();this._checkSelectionChange(e);this._poll=d.later(b,this,this._checkSelectionChange,e,true);},_checkSelectionChange:function(f){var e=a();if(e!==f._selection){f._selection=e;f._notifier.fire({selection:f._selection,pageX:f._x,pageY:f._y});}},_unpoll:function(){if(this._poll){this._poll.cancel();this._poll=null;}}});},"gallery-2012.07.18-13-22",{requires:["event-move"],skinnable:false});
View
2  build/gallery-event-selection/gallery-event-selection.js
@@ -131,4 +131,4 @@ Y.Event.define('selectionchange', {
});
-}, 'gallery-2012.07.05-20-01' ,{requires:['event-move'], skinnable:false});
+}, 'gallery-2012.07.18-13-22' ,{requires:['event-move'], skinnable:false});
View
408 build/gallery-l-system/gallery-l-system-debug.js
@@ -0,0 +1,408 @@
+YUI.add('gallery-l-system', function(Y) {
+
+/**
+ * @module gallery-l-system
+ */
+(function (Y, moduleName) {
+ 'use strict';
+
+ var _null = null,
+ _string_iterations = 'iterations',
+ _string_pattern = 'pattern',
+ _string_rules = 'rules',
+ _string_value = 'value',
+ _true = true,
+
+ _Array = Y.Array,
+ _Base = Y.Base,
+ _Lang = Y.Lang,
+ _RegExp = RegExp,
+
+ _isArray = _Lang.isArray,
+ _isFunction = _Lang.isFunction,
+ _isObject = _Lang.isObject,
+ _keys = Y.Object.keys,
+ _map = _Array.map,
+ _some = _Array.some;
+
+ /**
+ * @class LSystem
+ * @constructor
+ * @extends Base
+ * @param {Object} config Configuration Object.
+ */
+ Y.LSystem = _Base.create(moduleName, _Base, [], {
+ initializer: function () {
+ var me = this;
+
+ me.on([
+ 'axiomChange',
+ 'rulesChange'
+ ], me.restart, me);
+
+ me.restart();
+ },
+ /**
+ * Iterates the l-system's value.
+ * @method iterate
+ * @chainable
+ * @param {Number} [iterations] Optional. The number of iterations to
+ * perform. Defaults to 1. The l-system can only iterate forward so
+ * negative values aren't accepted.
+ */
+ iterate: function (iterations) {
+ var i = iterations && iterations >= 1 ? iterations : 1,
+ me = this,
+ pattern = me.get(_string_pattern),
+ rules = me.get(_string_rules),
+ value = me.get(_string_value),
+
+ replaceFunction = function (match, index, value) {
+ var replace = me._resolveMatch(rules[match], index, value, match);
+
+ if (replace === _null) {
+ return match;
+ }
+
+ return replace;
+ };
+
+ while (i > 0) {
+ i -= 1;
+ value = value.replace(pattern, replaceFunction);
+ }
+
+ return me._set(_string_iterations, me.get(_string_iterations) + iterations)._set(_string_value, value);
+ },
+ /**
+ * This method restarts the l-system and resets its value.
+ * @method restart
+ * @chainable
+ */
+ restart: function () {
+ var me = this;
+
+ return me._set(_string_iterations, 0)._set(_string_pattern, new _RegExp(_map(_keys(me.get(_string_rules)), function (key) {
+ if ('\\^$*+?.()|{}[]'.indexOf(key) !== -1) {
+ return '\\' + key;
+ }
+
+ return key;
+ }).join('|'), 'g'))._set(_string_value, me.get('axiom'));
+ },
+ /**
+ * @method _resolveMatch
+ * @param {Array|Object|String|WeightedList} ruleValue
+ * @param {Number} index
+ * @param {String} value
+ * @param {String} match
+ * @protected
+ * @return {String} Returns null if the rule doesn't apply.
+ */
+ _resolveMatch: function (ruleValue, index, value, match) {
+ var WeightedList = Y.WeightedList,
+
+ last,
+ me = this,
+ temp;
+
+ if (_isArray(ruleValue)) {
+ _some(ruleValue, function (ruleValue) {
+ temp = me._resolveMatch(ruleValue, index, value, match);
+
+ if (temp !== _null) {
+ return _true;
+ }
+ });
+
+ return temp;
+ }
+
+ if (_isObject(ruleValue)) {
+ if (WeightedList && ruleValue instanceof WeightedList) {
+ return me._resolveMatch(ruleValue.value(), index, value, match);
+ }
+
+ temp = ruleValue.fn;
+
+ if (_isFunction(temp)) {
+ return temp.call(ruleValue.ctx, match, index, value);
+ }
+
+ temp = ruleValue.first;
+
+ if (temp && index || temp === false && !index) {
+ return _null;
+ }
+
+ last = value.length - 1;
+ temp = ruleValue.last;
+
+ if (temp && index !== last || temp === false && index === last) {
+ return _null;
+ }
+
+ temp = ruleValue.next;
+
+ if (temp) {
+ if (WeightedList && temp instanceof WeightedList) {
+ temp = temp.value();
+ }
+
+ if (value.substr(index + 1, temp.length) !== temp) {
+ return _null;
+ }
+ }
+
+ temp = ruleValue.notNext;
+
+ if (temp) {
+ if (WeightedList && temp instanceof WeightedList) {
+ temp = temp.value();
+ }
+
+ if (value.substr(index + 1, temp.length) === temp) {
+ return _null;
+ }
+ }
+
+ temp = ruleValue.notPrev;
+
+ if (temp) {
+ if (!index) {
+ return _null;
+ }
+
+ if (WeightedList && temp instanceof WeightedList) {
+ temp = temp.value();
+ }
+
+ if (value.substr(index - temp.length, temp.length) === temp) {
+ return _null;
+ }
+ }
+
+ temp = ruleValue.prev;
+
+ if (temp) {
+ if (!index) {
+ return _null;
+ }
+
+ if (WeightedList && temp instanceof WeightedList) {
+ temp = temp.value();
+ }
+
+ if (value.substr(index - temp.length, temp.length) !== temp) {
+ return _null;
+ }
+ }
+
+ return me._resolveMatch(ruleValue.value, index, value, match);
+ }
+
+ return ruleValue;
+ }
+ }, {
+ ATTRS: {
+ /**
+ * The axiom is the initial value of the l-system. Note: If the
+ * axiom is changed after the l-system has been iterated, the
+ * l-system will be restarted.
+ * @attribute axiom
+ * @default ''
+ * @type String
+ */
+ axiom: {
+ value: ''
+ },
+ /**
+ * The number of iterations the l-system has been set to. This
+ * attribute is read only; use the iterate method to iterate the
+ * l-system.
+ * @attribute iterations
+ * @default 0
+ * @readonly
+ * @type Number
+ */
+ iterations: {
+ readOnly: _true,
+ value: 0
+ },
+ /**
+ * The regular expression that is used to help apply the rules
+ * during iteration.
+ * @attribute pattern
+ * @protected
+ * @readonly
+ * @type RegExp
+ */
+ pattern: {
+ readOnly: _true,
+ value: _null
+ },
+ /**
+ * The l-system's rules. Note: If the rules are changed after the
+ * l-system has been iterated, the l-system will be restarted. If
+ * you read this object and manipulate it directly, you must call
+ * the restart method before iterating the l-system again otherwise
+ * it will yield unknown results.
+ *
+ * The rules are key/value pairs. The rules object's keys should be
+ * single characters. In the simplest case, the rules object's
+ * values are strings. For example, with this rules object
+ * {a: 'abc'}, every time the character 'a' is found in the
+ * l-system's value, it will be replaced with the string 'abc'.
+ *
+ * The rules object's values may also be objects for more control
+ * over when the rule is applied. For example, with this rules
+ * object {a: {prev: 'ccc', value: 'abc'}}, every time the character
+ * 'a' is found in the l-system's value and the previous characters
+ * in the l-system's value are 'ccc', the 'a' will be replaced with
+ * the string 'abc'. In the simplest case, the value property is a
+ * string but it may be any value that can be one of the rule
+ * object's values. Here is a list of the properties that affect
+ * when this rule is applied:
+ * <dl>
+ * <dt>
+ * first
+ * </dt>
+ * <dd>
+ * If the first property is defined and is a truthy value,
+ * the rule will only be applied if the matched character is
+ * the first character in the l-system's value. If the
+ * first property is set to false, the rule will only be
+ * applied if the matched character is not the first
+ * character in the l-system's value.
+ * </dd>
+ * <dt>
+ * last
+ * </dt>
+ * <dd>
+ * If the last property is defined and is a truthy value,
+ * the rule will only be applied if the matched character is
+ * the last character in the l-system's value. If the last
+ * property is set to false, the rule will only be applied
+ * if the matched character is not the last character in the
+ * l-system's value.
+ * </dd>
+ * <dt>
+ * next
+ * </dt>
+ * <dd>
+ * If the next property is defined, it should be a string of
+ * one or more characters. The rule will only be applied if
+ * the matched character is followed by this string of
+ * characters exactly.
+ *
+ * The next property may also be a weighted list of strings
+ * of one or more characters. In this case, the value will
+ * be selected from the weighted list at random.
+ * </dd>
+ * <dt>
+ * notNext
+ * </dt>
+ * <dd>
+ * If the notNext property is defined, it should be a string
+ * of one or more characters. The rule will only be applied
+ * if the matched character is not followed by this string
+ * of characters exactly.
+ *
+ * The notNext property may also be a weighted list of
+ * strings of one or more characters. In this case, the
+ * value will be selected from the weighted list at random.
+ * </dd>
+ * <dt>
+ * notPrev
+ * </dt>
+ * <dd>
+ * If the notPrev property is defined, it should be a string
+ * of one or more characters. The rule will only be applied
+ * if the matched character is not preceded by this string
+ * of characters exactly.
+ *
+ * The notPrev property may also be a weighted list of
+ * strings of one or more characters. In this case, the
+ * value will be selected from the weighted list at random.
+ * </dd>
+ * <dt>
+ * prev
+ * </dt>
+ * <dd>
+ * If the prev property is defined, it should be a string of
+ * one or more characters. The rule will only be applied if
+ * the matched character is preceded by this string of
+ * characters exactly.
+ *
+ * The prev property may also be a weighted list of strings
+ * of one or more characters. In this case, the value will
+ * be selected from the weighted list at random.
+ * </dd>
+ * </dl>
+ *
+ * For even further control, the rules object's values may be
+ * objects with a fn property. The fn property should be a function
+ * that accepts three arguments:
+ * <dl>
+ * <dt>
+ * match
+ * </dt>
+ * <dd>
+ * String. The single character that was matched.
+ * </dd>
+ * <dt>
+ * index
+ * </dt>
+ * <dd>
+ * Number. The index of the matched character within the
+ * l-system's value.
+ * </dd>
+ * <dt>
+ * value
+ * </dt>
+ * <dd>
+ * String. The l-system's current value.
+ * </dd>
+ * </dl>
+ * The function should return a string or null. The rule will only
+ * be applied if the function does not return null. The object may
+ * also have a ctx property which will be used as the execution
+ * context for the function.
+ *
+ * Multiple rules may be given for a single character by providing
+ * an array as a rules object's value. The array may contain any
+ * value that is acceptable as a rules object's value. The array
+ * items will be processed in order; the first rule that applies
+ * will be used. Because of this, the array items should usually be
+ * one of the ojects described above. The array may contain string
+ * items, but since string rules are always applied, there should
+ * only ever be one string item in the array and it should be the
+ * last item in the array.
+ *
+ * A rules object's value may also be a weighted list of any of the
+ * other values described above. In this case, the values will be
+ * selected from the weighted list at random.
+ * @attribute rules
+ * @default {}
+ * @type Object
+ */
+ rules: {
+ value: {}
+ },
+ /**
+ * The current value of the l-system.
+ * @attribute value
+ * @default ''
+ * @readonly
+ * @type String
+ */
+ value: {
+ readOnly: _true,
+ value: ''
+ }
+ }
+ });
+}(Y, arguments[1]));
+
+
+}, 'gallery-2012.07.18-13-22' ,{requires:['array-extras', 'base'], skinnable:false, optional:['gallery-weighted-list']});
View
1  build/gallery-l-system/gallery-l-system-min.js
@@ -0,0 +1 @@
+YUI.add("gallery-l-system",function(a){(function(e,p){var h=null,s="iterations",k="pattern",i="rules",l="value",n=true,g=e.Array,d=e.Base,q=e.Lang,m=RegExp,j=q.isArray,r=q.isFunction,o=q.isObject,f=e.Object.keys,b=g.map,c=g.some;e.LSystem=d.create(p,d,[],{initializer:function(){var t=this;t.on(["axiomChange","rulesChange"],t.restart,t);t.restart();},iterate:function(v){var t=v&&v>=1?v:1,u=this,x=u.get(k),z=u.get(i),w=u.get(l),y=function(B,A,D){var C=u._resolveMatch(z[B],A,D,B);if(C===h){return B;}return C;};while(t>0){t-=1;w=w.replace(x,y);}return u._set(s,u.get(s)+v)._set(l,w);},restart:function(){var t=this;return t._set(s,0)._set(k,new m(b(f(t.get(i)),function(u){if("\\^$*+?.()|{}[]".indexOf(u)!==-1){return"\\"+u;}return u;}).join("|"),"g"))._set(l,t.get("axiom"));},_resolveMatch:function(A,v,y,u){var z=e.WeightedList,x,w=this,t;if(j(A)){c(A,function(B){t=w._resolveMatch(B,v,y,u);if(t!==h){return n;}});return t;}if(o(A)){if(z&&A instanceof z){return w._resolveMatch(A.value(),v,y,u);}t=A.fn;if(r(t)){return t.call(A.ctx,u,v,y);}t=A.first;if(t&&v||t===false&&!v){return h;}x=y.length-1;t=A.last;if(t&&v!==x||t===false&&v===x){return h;}t=A.next;if(t){if(z&&t instanceof z){t=t.value();}if(y.substr(v+1,t.length)!==t){return h;}}t=A.notNext;if(t){if(z&&t instanceof z){t=t.value();}if(y.substr(v+1,t.length)===t){return h;}}t=A.notPrev;if(t){if(!v){return h;}if(z&&t instanceof z){t=t.value();}if(y.substr(v-t.length,t.length)===t){return h;}}t=A.prev;if(t){if(!v){return h;}if(z&&t instanceof z){t=t.value();}if(y.substr(v-t.length,t.length)!==t){return h;}}return w._resolveMatch(A.value,v,y,u);}return A;}},{ATTRS:{axiom:{value:""},iterations:{readOnly:n,value:0},pattern:{readOnly:n,value:h},rules:{value:{}},value:{readOnly:n,value:""}}});}(a,arguments[1]));},"gallery-2012.07.18-13-22",{requires:["array-extras","base"],skinnable:false,optional:["gallery-weighted-list"]});
View
408 build/gallery-l-system/gallery-l-system.js
@@ -0,0 +1,408 @@
+YUI.add('gallery-l-system', function(Y) {
+
+/**
+ * @module gallery-l-system
+ */
+(function (Y, moduleName) {
+ 'use strict';
+
+ var _null = null,
+ _string_iterations = 'iterations',
+ _string_pattern = 'pattern',
+ _string_rules = 'rules',
+ _string_value = 'value',
+ _true = true,
+
+ _Array = Y.Array,
+ _Base = Y.Base,
+ _Lang = Y.Lang,
+ _RegExp = RegExp,
+
+ _isArray = _Lang.isArray,
+ _isFunction = _Lang.isFunction,
+ _isObject = _Lang.isObject,
+ _keys = Y.Object.keys,
+ _map = _Array.map,
+ _some = _Array.some;
+
+ /**
+ * @class LSystem
+ * @constructor
+ * @extends Base
+ * @param {Object} config Configuration Object.
+ */
+ Y.LSystem = _Base.create(moduleName, _Base, [], {
+ initializer: function () {
+ var me = this;
+
+ me.on([
+ 'axiomChange',
+ 'rulesChange'
+ ], me.restart, me);
+
+ me.restart();
+ },
+ /**
+ * Iterates the l-system's value.
+ * @method iterate
+ * @chainable
+ * @param {Number} [iterations] Optional. The number of iterations to
+ * perform. Defaults to 1. The l-system can only iterate forward so
+ * negative values aren't accepted.
+ */
+ iterate: function (iterations) {
+ var i = iterations && iterations >= 1 ? iterations : 1,
+ me = this,
+ pattern = me.get(_string_pattern),
+ rules = me.get(_string_rules),
+ value = me.get(_string_value),
+
+ replaceFunction = function (match, index, value) {
+ var replace = me._resolveMatch(rules[match], index, value, match);
+
+ if (replace === _null) {
+ return match;
+ }
+
+ return replace;
+ };
+
+ while (i > 0) {
+ i -= 1;
+ value = value.replace(pattern, replaceFunction);
+ }
+
+ return me._set(_string_iterations, me.get(_string_iterations) + iterations)._set(_string_value, value);
+ },
+ /**
+ * This method restarts the l-system and resets its value.
+ * @method restart
+ * @chainable
+ */
+ restart: function () {
+ var me = this;
+
+ return me._set(_string_iterations, 0)._set(_string_pattern, new _RegExp(_map(_keys(me.get(_string_rules)), function (key) {
+ if ('\\^$*+?.()|{}[]'.indexOf(key) !== -1) {
+ return '\\' + key;
+ }
+
+ return key;
+ }).join('|'), 'g'))._set(_string_value, me.get('axiom'));
+ },
+ /**
+ * @method _resolveMatch
+ * @param {Array|Object|String|WeightedList} ruleValue
+ * @param {Number} index
+ * @param {String} value
+ * @param {String} match
+ * @protected
+ * @return {String} Returns null if the rule doesn't apply.
+ */
+ _resolveMatch: function (ruleValue, index, value, match) {
+ var WeightedList = Y.WeightedList,
+
+ last,
+ me = this,
+ temp;
+
+ if (_isArray(ruleValue)) {
+ _some(ruleValue, function (ruleValue) {
+ temp = me._resolveMatch(ruleValue, index, value, match);
+
+ if (temp !== _null) {
+ return _true;
+ }
+ });
+
+ return temp;
+ }
+
+ if (_isObject(ruleValue)) {
+ if (WeightedList && ruleValue instanceof WeightedList) {
+ return me._resolveMatch(ruleValue.value(), index, value, match);
+ }
+
+ temp = ruleValue.fn;
+
+ if (_isFunction(temp)) {
+ return temp.call(ruleValue.ctx, match, index, value);
+ }
+
+ temp = ruleValue.first;
+
+ if (temp && index || temp === false && !index) {
+ return _null;
+ }
+
+ last = value.length - 1;
+ temp = ruleValue.last;
+
+ if (temp && index !== last || temp === false && index === last) {
+ return _null;
+ }
+
+ temp = ruleValue.next;
+
+ if (temp) {
+ if (WeightedList && temp instanceof WeightedList) {
+ temp = temp.value();
+ }
+
+ if (value.substr(index + 1, temp.length) !== temp) {
+ return _null;
+ }
+ }
+
+ temp = ruleValue.notNext;
+
+ if (temp) {
+ if (WeightedList && temp instanceof WeightedList) {
+ temp = temp.value();
+ }
+
+ if (value.substr(index + 1, temp.length) === temp) {
+ return _null;
+ }
+ }
+
+ temp = ruleValue.notPrev;
+
+ if (temp) {
+ if (!index) {
+ return _null;
+ }
+
+ if (WeightedList && temp instanceof WeightedList) {
+ temp = temp.value();
+ }
+
+ if (value.substr(index - temp.length, temp.length) === temp) {
+ return _null;
+ }
+ }
+
+ temp = ruleValue.prev;
+
+ if (temp) {
+ if (!index) {
+ return _null;
+ }
+
+ if (WeightedList && temp instanceof WeightedList) {
+ temp = temp.value();
+ }
+
+ if (value.substr(index - temp.length, temp.length) !== temp) {
+ return _null;
+ }
+ }
+
+ return me._resolveMatch(ruleValue.value, index, value, match);
+ }
+
+ return ruleValue;
+ }
+ }, {
+ ATTRS: {
+ /**
+ * The axiom is the initial value of the l-system. Note: If the
+ * axiom is changed after the l-system has been iterated, the
+ * l-system will be restarted.
+ * @attribute axiom
+ * @default ''
+ * @type String
+ */
+ axiom: {
+ value: ''
+ },
+ /**
+ * The number of iterations the l-system has been set to. This
+ * attribute is read only; use the iterate method to iterate the
+ * l-system.
+ * @attribute iterations
+ * @default 0
+ * @readonly
+ * @type Number
+ */
+ iterations: {
+ readOnly: _true,
+ value: 0
+ },
+ /**
+ * The regular expression that is used to help apply the rules
+ * during iteration.
+ * @attribute pattern
+ * @protected
+ * @readonly
+ * @type RegExp
+ */
+ pattern: {
+ readOnly: _true,
+ value: _null
+ },
+ /**
+ * The l-system's rules. Note: If the rules are changed after the
+ * l-system has been iterated, the l-system will be restarted. If
+ * you read this object and manipulate it directly, you must call
+ * the restart method before iterating the l-system again otherwise
+ * it will yield unknown results.
+ *
+ * The rules are key/value pairs. The rules object's keys should be
+ * single characters. In the simplest case, the rules object's
+ * values are strings. For example, with this rules object
+ * {a: 'abc'}, every time the character 'a' is found in the
+ * l-system's value, it will be replaced with the string 'abc'.
+ *
+ * The rules object's values may also be objects for more control
+ * over when the rule is applied. For example, with this rules
+ * object {a: {prev: 'ccc', value: 'abc'}}, every time the character
+ * 'a' is found in the l-system's value and the previous characters
+ * in the l-system's value are 'ccc', the 'a' will be replaced with
+ * the string 'abc'. In the simplest case, the value property is a
+ * string but it may be any value that can be one of the rule
+ * object's values. Here is a list of the properties that affect
+ * when this rule is applied:
+ * <dl>
+ * <dt>
+ * first
+ * </dt>
+ * <dd>
+ * If the first property is defined and is a truthy value,
+ * the rule will only be applied if the matched character is
+ * the first character in the l-system's value. If the
+ * first property is set to false, the rule will only be
+ * applied if the matched character is not the first
+ * character in the l-system's value.
+ * </dd>
+ * <dt>
+ * last
+ * </dt>
+ * <dd>
+ * If the last property is defined and is a truthy value,
+ * the rule will only be applied if the matched character is
+ * the last character in the l-system's value. If the last
+ * property is set to false, the rule will only be applied
+ * if the matched character is not the last character in the
+ * l-system's value.
+ * </dd>
+ * <dt>
+ * next
+ * </dt>
+ * <dd>
+ * If the next property is defined, it should be a string of
+ * one or more characters. The rule will only be applied if
+ * the matched character is followed by this string of
+ * characters exactly.
+ *
+ * The next property may also be a weighted list of strings
+ * of one or more characters. In this case, the value will
+ * be selected from the weighted list at random.
+ * </dd>
+ * <dt>
+ * notNext
+ * </dt>
+ * <dd>
+ * If the notNext property is defined, it should be a string
+ * of one or more characters. The rule will only be applied
+ * if the matched character is not followed by this string
+ * of characters exactly.
+ *
+ * The notNext property may also be a weighted list of
+ * strings of one or more characters. In this case, the
+ * value will be selected from the weighted list at random.
+ * </dd>
+ * <dt>
+ * notPrev
+ * </dt>
+ * <dd>
+ * If the notPrev property is defined, it should be a string
+ * of one or more characters. The rule will only be applied
+ * if the matched character is not preceded by this string
+ * of characters exactly.
+ *
+ * The notPrev property may also be a weighted list of
+ * strings of one or more characters. In this case, the
+ * value will be selected from the weighted list at random.
+ * </dd>
+ * <dt>
+ * prev
+ * </dt>
+ * <dd>
+ * If the prev property is defined, it should be a string of
+ * one or more characters. The rule will only be applied if
+ * the matched character is preceded by this string of
+ * characters exactly.
+ *
+ * The prev property may also be a weighted list of strings
+ * of one or more characters. In this case, the value will
+ * be selected from the weighted list at random.
+ * </dd>
+ * </dl>
+ *
+ * For even further control, the rules object's values may be
+ * objects with a fn property. The fn property should be a function
+ * that accepts three arguments:
+ * <dl>
+ * <dt>
+ * match
+ * </dt>
+ * <dd>
+ * String. The single character that was matched.
+ * </dd>
+ * <dt>
+ * index
+ * </dt>
+ * <dd>
+ * Number. The index of the matched character within the
+ * l-system's value.
+ * </dd>
+ * <dt>
+ * value
+ * </dt>
+ * <dd>
+ * String. The l-system's current value.
+ * </dd>
+ * </dl>
+ * The function should return a string or null. The rule will only
+ * be applied if the function does not return null. The object may
+ * also have a ctx property which will be used as the execution
+ * context for the function.
+ *
+ * Multiple rules may be given for a single character by providing
+ * an array as a rules object's value. The array may contain any
+ * value that is acceptable as a rules object's value. The array
+ * items will be processed in order; the first rule that applies
+ * will be used. Because of this, the array items should usually be
+ * one of the ojects described above. The array may contain string
+ * items, but since string rules are always applied, there should
+ * only ever be one string item in the array and it should be the
+ * last item in the array.
+ *
+ * A rules object's value may also be a weighted list of any of the
+ * other values described above. In this case, the values will be
+ * selected from the weighted list at random.
+ * @attribute rules
+ * @default {}
+ * @type Object
+ */
+ rules: {
+ value: {}
+ },
+ /**
+ * The current value of the l-system.
+ * @attribute value
+ * @default ''
+ * @readonly
+ * @type String
+ */
+ value: {
+ readOnly: _true,
+ value: ''
+ }
+ }
+ });
+}(Y, arguments[1]));
+
+
+}, 'gallery-2012.07.18-13-22' ,{requires:['array-extras', 'base'], skinnable:false, optional:['gallery-weighted-list']});
View
1,643 build/gallery-markdown/gallery-markdown-debug.js
@@ -0,0 +1,1643 @@
+YUI.add('gallery-markdown', function(Y) {
+
+// Released under MIT license
+// Copyright (c) 2009-2010 Dominic Baggott
+// Copyright (c) 2009-2010 Ash Berlin
+// Copyright (c) 2011 Christoph Dorn <christoph@christophdorn.com> (http://www.christophdorn.com)
+
+/**
+A wrapper around the fantastic Markdown library at https://github.com/evilstreak/markdown-js
+
+@module gallery-markdown
+
+**/
+
+/**
+A YUI wrapper around the fantastic Markdown library at https://github.com/evilstreak/markdown-js.
+This supports several dialects and works very well. I (jshirley) am not the author, merely the one maintaining the YUI wrapper.
+
+Below is the original documentation:
+
+Markdown processing in Javascript done right. We have very particular views
+on what constitutes 'right' which include:
+
+ - produces well-formed HTML (this means that em and strong nesting is
+ important)
+
+ - has an intermediate representation to allow processing of parsed data (We
+ in fact have two, both as [JsonML]: a markdown tree and an HTML tree).
+
+ - is easily extensible to add new dialects without having to rewrite the
+ entire parsing mechanics
+
+ - has a good test suite
+
+This implementation fulfills all of these (except that the test suite could
+do with expanding to automatically run all the fixtures from other Markdown
+implementations.)
+
+##### Intermediate Representation
+
+*TODO* Talk about this :) Its JsonML, but document the node names we use.
+
+[JsonML]: http://jsonml.org/ "JSON Markup Language"
+
+**/
+
+(function( expose ) {
+
+var Markdown = expose.Markdown = function Markdown(dialect) {
+ switch (typeof dialect) {
+ case "undefined":
+ this.dialect = Markdown.dialects.Gruber;
+ break;
+ case "object":
+ this.dialect = dialect;
+ break;
+ default:
+ if (dialect in Markdown.dialects) {
+ this.dialect = Markdown.dialects[dialect];
+ }
+ else {
+ throw new Error("Unknown Markdown dialect '" + String(dialect) + "'");
+ }
+ break;
+ }
+ this.em_state = [];
+ this.strong_state = [];
+ this.debug_indent = "";
+};
+
+/**
+Parse `markdown` and return a markdown document as a Markdown.JsonML tree.
+
+@method parse
+@param markdown {String} The Markdown string to parse
+@param dialect {String} The Markdown dialect to use, defaults to gruber
+@static
+
+**/
+expose.parse = function( source, dialect ) {
+ // dialect will default if undefined
+ var md = new Markdown( dialect );
+ return md.toTree( source );
+};
+
+/**
+Take markdown (either as a string or as a JsonML tree) and run it through
+[[toHTMLTree]] then turn it into a well-formated HTML fragment.
+
+@method toHTML
+@static
+@param source {String} markdown string to parse
+@param dialect {String} dialect to use
+
+**/
+expose.toHTML = function toHTML( source , dialect , options ) {
+ var input = expose.toHTMLTree( source , dialect , options );
+
+ return expose.renderJsonML( input );
+};
+
+/**
+Turn markdown into HTML, represented as a JsonML tree. If a string is given
+to this function, it is first parsed into a markdown tree by calling
+[[parse]].
+
+@method toHTMLTree
+@static
+@param markdown {String | Object } markdown string to parse or already parsed tree
+@param dialect {String} the dialect to use, defaults to gruber
+**/
+expose.toHTMLTree = function toHTMLTree( input, dialect , options ) {
+ // convert string input to an MD tree
+ if ( typeof input ==="string" ) input = this.parse( input, dialect );
+
+ // Now convert the MD tree to an HTML tree
+
+ // remove references from the tree
+ var attrs = extract_attr( input ),
+ refs = {};
+
+ if ( attrs && attrs.references ) {
+ refs = attrs.references;
+ }
+
+ var html = convert_tree_to_html( input, refs , options );
+ merge_text_nodes( html );
+ return html;
+};
+
+// For Spidermonkey based engines
+function mk_block_toSource() {
+ return "Markdown.mk_block( " +
+ uneval(this.toString()) +
+ ", " +
+ uneval(this.trailing) +
+ ", " +
+ uneval(this.lineNumber) +
+ " )";
+}
+
+// node
+function mk_block_inspect() {
+ var util = require('util');
+ return "Markdown.mk_block( " +
+ util.inspect(this.toString()) +
+ ", " +
+ util.inspect(this.trailing) +
+ ", " +
+ util.inspect(this.lineNumber) +
+ " )";
+
+}
+
+var mk_block = Markdown.mk_block = function(block, trail, line) {
+ // Be helpful for default case in tests.
+ if ( arguments.length == 1 ) trail = "\n\n";
+
+ var s = new String(block);
+ s.trailing = trail;
+ // To make it clear its not just a string
+ s.inspect = mk_block_inspect;
+ s.toSource = mk_block_toSource;
+
+ if (line != undefined)
+ s.lineNumber = line;
+
+ return s;
+};
+
+function count_lines( str ) {
+ var n = 0, i = -1;
+ while ( ( i = str.indexOf('\n', i+1) ) !== -1) n++;
+ return n;
+}
+
+// Internal - split source into rough blocks
+Markdown.prototype.split_blocks = function splitBlocks( input, startLine ) {
+ // [\s\S] matches _anything_ (newline or space)
+ var re = /([\s\S]+?)($|\n(?:\s*\n|$)+)/g,
+ blocks = [],
+ m;
+
+ var line_no = 1;
+
+ if ( ( m = /^(\s*\n)/.exec(input) ) != null ) {
+ // skip (but count) leading blank lines
+ line_no += count_lines( m[0] );
+ re.lastIndex = m[0].length;
+ }
+
+ while ( ( m = re.exec(input) ) !== null ) {
+ blocks.push( mk_block( m[1], m[2], line_no ) );
+ line_no += count_lines( m[0] );
+ }
+
+ return blocks;
+};
+
+/**
+Process `block` and return an array of JsonML nodes representing `block`.
+
+It does this by asking each block level function in the dialect to process
+the block until one can. Succesful handling is indicated by returning an
+array (with zero or more JsonML nodes), failure by a false value.
+
+Blocks handlers are responsible for calling [[Markdown#processInline]]
+themselves as appropriate.
+
+If the blocks were split incorrectly or adjacent blocks need collapsing you
+can adjust `next` in place using shift/splice etc.
+
+If any of this default behaviour is not right for the dialect, you can
+define a `__call__` method on the dialect that will get invoked to handle
+the block processing.
+
+@method processBlock
+@protected
+@static
+@param block {String} the block to process
+@param next {Array} following blocks
+**/
+Markdown.prototype.processBlock = function processBlock( block, next ) {
+ var cbs = this.dialect.block,
+ ord = cbs.__order__;
+
+ if ( "__call__" in cbs ) {
+ return cbs.__call__.call(this, block, next);
+ }
+
+ for ( var i = 0; i < ord.length; i++ ) {
+ //D:this.debug( "Testing", ord[i] );
+ var res = cbs[ ord[i] ].call( this, block, next );
+ if ( res ) {
+ //D:this.debug(" matched");
+ if ( !isArray(res) || ( res.length > 0 && !( isArray(res[0]) ) ) )
+ this.debug(ord[i], "didn't return a proper array");
+ //D:this.debug( "" );
+ return res;
+ }
+ }
+
+ // Uhoh! no match! Should we throw an error?
+ return [];
+};
+
+Markdown.prototype.processInline = function processInline( block ) {
+ return this.dialect.inline.__call__.call( this, String( block ) );
+};
+
+/**
+Parse `source` into a JsonML tree representing the markdown document.
+
+@method toTree
+@protected
+@static
+@param source {String} markdown source to parse.
+@param custom_root {Object} A previous tree to append to
+**/
+// custom_tree means set this.tree to `custom_tree` and restore old value on return
+Markdown.prototype.toTree = function toTree( source, custom_root ) {
+ var blocks = source instanceof Array ? source : this.split_blocks( source );
+
+ // Make tree a member variable so its easier to mess with in extensions
+ var old_tree = this.tree;
+ try {
+ this.tree = custom_root || this.tree || [ "markdown" ];
+
+ blocks:
+ while ( blocks.length ) {
+ var b = this.processBlock( blocks.shift(), blocks );
+
+ // Reference blocks and the like won't return any content
+ if ( !b.length ) continue blocks;
+
+ this.tree.push.apply( this.tree, b );
+ }
+ return this.tree;
+ }
+ finally {
+ if ( custom_root ) {
+ this.tree = old_tree;
+ }
+ }
+};
+
+// Noop by default
+Markdown.prototype.debug = function () {
+ var args = Array.prototype.slice.call( arguments);
+ args.unshift(this.debug_indent);
+ if (typeof print !== "undefined")
+ print.apply( print, args );
+ if (typeof console !== "undefined" && typeof console.log !== "undefined")
+ console.log.apply( null, args );
+}
+
+Markdown.prototype.loop_re_over_block = function( re, block, cb ) {
+ // Dont use /g regexps with this
+ var m,
+ b = block.valueOf();
+
+ while ( b.length && (m = re.exec(b) ) != null) {
+ b = b.substr( m[0].length );
+ cb.call(this, m);
+ }
+ return b;
+};
+
+/**
+ * Markdown.dialects
+ *
+ * Namespace of built-in dialects.
+ **/
+Markdown.dialects = {};
+
+/**
+ * Markdown.dialects.Gruber
+ *
+ * The default dialect that follows the rules set out by John Gruber's
+ * markdown.pl as closely as possible. Well actually we follow the behaviour of
+ * that script which in some places is not exactly what the syntax web page
+ * says.
+ **/
+Markdown.dialects.Gruber = {
+ block: {
+ atxHeader: function atxHeader( block, next ) {
+ var m = block.match( /^(#{1,6})\s*(.*?)\s*#*\s*(?:\n|$)/ );
+
+ if ( !m ) return undefined;
+
+ var header = [ "header", { level: m[ 1 ].length } ];
+ Array.prototype.push.apply(header, this.processInline(m[ 2 ]));
+
+ if ( m[0].length < block.length )
+ next.unshift( mk_block( block.substr( m[0].length ), block.trailing, block.lineNumber + 2 ) );
+
+ return [ header ];
+ },
+
+ setextHeader: function setextHeader( block, next ) {
+ var m = block.match( /^(.*)\n([-=])\2\2+(?:\n|$)/ );
+
+ if ( !m ) return undefined;
+
+ var level = ( m[ 2 ] === "=" ) ? 1 : 2;
+ var header = [ "header", { level : level }, m[ 1 ] ];
+
+ if ( m[0].length < block.length )
+ next.unshift( mk_block( block.substr( m[0].length ), block.trailing, block.lineNumber + 2 ) );
+
+ return [ header ];
+ },
+
+ code: function code( block, next ) {
+ // | Foo
+ // |bar
+ // should be a code block followed by a paragraph. Fun
+ //
+ // There might also be adjacent code block to merge.
+
+ var ret = [],
+ re = /^(?: {0,3}\t| {4})(.*)\n?/,
+ lines;
+
+ // 4 spaces + content
+ if ( !block.match( re ) ) return undefined;
+
+ block_search:
+ do {
+ // Now pull out the rest of the lines
+ var b = this.loop_re_over_block(
+ re, block.valueOf(), function( m ) { ret.push( m[1] ); } );
+
+ if (b.length) {
+ // Case alluded to in first comment. push it back on as a new block
+ next.unshift( mk_block(b, block.trailing) );
+ break block_search;
+ }
+ else if (next.length) {
+ // Check the next block - it might be code too
+ if ( !next[0].match( re ) ) break block_search;
+
+ // Pull how how many blanks lines follow - minus two to account for .join
+ ret.push ( block.trailing.replace(/[^\n]/g, '').substring(2) );
+
+ block = next.shift();
+ }
+ else {
+ break block_search;
+ }
+ } while (true);
+
+ return [ [ "code_block", ret.join("\n") ] ];
+ },
+
+ horizRule: function horizRule( block, next ) {
+ // this needs to find any hr in the block to handle abutting blocks
+ var m = block.match( /^(?:([\s\S]*?)\n)?[ \t]*([-_*])(?:[ \t]*\2){2,}[ \t]*(?:\n([\s\S]*))?$/ );
+
+ if ( !m ) {
+ return undefined;
+ }
+
+ var jsonml = [ [ "hr" ] ];
+
+ // if there's a leading abutting block, process it
+ if ( m[ 1 ] ) {
+ jsonml.unshift.apply( jsonml, this.processBlock( m[ 1 ], [] ) );
+ }
+
+ // if there's a trailing abutting block, stick it into next
+ if ( m[ 3 ] ) {
+ next.unshift( mk_block( m[ 3 ] ) );
+ }
+
+ return jsonml;
+ },
+
+ // There are two types of lists. Tight and loose. Tight lists have no whitespace
+ // between the items (and result in text just in the <li>) and loose lists,
+ // which have an empty line between list items, resulting in (one or more)
+ // paragraphs inside the <li>.
+ //
+ // There are all sorts weird edge cases about the original markdown.pl's
+ // handling of lists:
+ //
+ // * Nested lists are supposed to be indented by four chars per level. But
+ // if they aren't, you can get a nested list by indenting by less than
+ // four so long as the indent doesn't match an indent of an existing list
+ // item in the 'nest stack'.
+ //
+ // * The type of the list (bullet or number) is controlled just by the
+ // first item at the indent. Subsequent changes are ignored unless they
+ // are for nested lists
+ //
+ lists: (function( ) {
+ // Use a closure to hide a few variables.
+ var any_list = "[*+-]|\\d+\\.",
+ bullet_list = /[*+-]/,
+ number_list = /\d+\./,
+ // Capture leading indent as it matters for determining nested lists.
+ is_list_re = new RegExp( "^( {0,3})(" + any_list + ")[ \t]+" ),
+ indent_re = "(?: {0,3}\\t| {4})";
+
+ // TODO: Cache this regexp for certain depths.
+ // Create a regexp suitable for matching an li for a given stack depth
+ function regex_for_depth( depth ) {
+
+ return new RegExp(
+ // m[1] = indent, m[2] = list_type
+ "(?:^(" + indent_re + "{0," + depth + "} {0,3})(" + any_list + ")\\s+)|" +
+ // m[3] = cont
+ "(^" + indent_re + "{0," + (depth-1) + "}[ ]{0,4})"
+ );
+ }
+ function expand_tab( input ) {
+ return input.replace( / {0,3}\t/g, " " );
+ }
+
+ // Add inline content `inline` to `li`. inline comes from processInline
+ // so is an array of content
+ function add(li, loose, inline, nl) {
+ if (loose) {
+ li.push( [ "para" ].concat(inline) );
+ return;
+ }
+ // Hmmm, should this be any block level element or just paras?
+ var add_to = li[li.length -1] instanceof Array && li[li.length - 1][0] == "para"
+ ? li[li.length -1]
+ : li;
+
+ // If there is already some content in this list, add the new line in
+ if (nl && li.length > 1) inline.unshift(nl);
+
+ for (var i=0; i < inline.length; i++) {
+ var what = inline[i],
+ is_str = typeof what == "string";
+ if (is_str && add_to.length > 1 && typeof add_to[add_to.length-1] == "string" ) {
+ add_to[ add_to.length-1 ] += what;
+ }
+ else {
+ add_to.push( what );
+ }
+ }
+ }
+
+ // contained means have an indent greater than the current one. On
+ // *every* line in the block
+ function get_contained_blocks( depth, blocks ) {
+
+ var re = new RegExp( "^(" + indent_re + "{" + depth + "}.*?\\n?)*$" ),
+ replace = new RegExp("^" + indent_re + "{" + depth + "}", "gm"),
+ ret = [];
+
+ while ( blocks.length > 0 ) {
+ if ( re.exec( blocks[0] ) ) {
+ var b = blocks.shift(),
+ // Now remove that indent
+ x = b.replace( replace, "");
+
+ ret.push( mk_block( x, b.trailing, b.lineNumber ) );
+ }
+ break;
+ }
+ return ret;
+ }
+
+ // passed to stack.forEach to turn list items up the stack into paras
+ function paragraphify(s, i, stack) {
+ var list = s.list;
+ var last_li = list[list.length-1];
+
+ if (last_li[1] instanceof Array && last_li[1][0] == "para") {