bake-toolkit 2.18.0 → 2.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/_build/html/_sources/changelog.txt +5 -0
  3. data/documentation/_build/html/_sources/index.txt +1 -1
  4. data/documentation/_build/html/_sources/quickstart/quickstart.txt +5 -5
  5. data/documentation/_build/html/_sources/syntax/variable_substitutions.txt +15 -15
  6. data/documentation/_build/html/_sources/tips_and_tricks/how_to_use_bake_with_cygwin.txt +20 -7
  7. data/documentation/_build/html/_static/basic.css +598 -598
  8. data/documentation/_build/html/_static/bootstrap-2.3.2/css/bootstrap-responsive.css +1109 -1109
  9. data/documentation/_build/html/_static/bootstrap-2.3.2/css/bootstrap-responsive.min.css +9 -9
  10. data/documentation/_build/html/_static/bootstrap-2.3.2/css/bootstrap.css +6167 -6167
  11. data/documentation/_build/html/_static/bootstrap-2.3.2/css/bootstrap.min.css +9 -9
  12. data/documentation/_build/html/_static/bootstrap-2.3.2/js/bootstrap.js +2287 -2287
  13. data/documentation/_build/html/_static/bootstrap-2.3.2/js/bootstrap.min.js +5 -5
  14. data/documentation/_build/html/_static/bootstrap-3.3.4/css/bootstrap-theme.css +476 -476
  15. data/documentation/_build/html/_static/bootstrap-3.3.4/css/bootstrap-theme.min.css +4 -4
  16. data/documentation/_build/html/_static/bootstrap-3.3.4/css/bootstrap.css +6584 -6584
  17. data/documentation/_build/html/_static/bootstrap-3.3.4/css/bootstrap.min.css +4 -4
  18. data/documentation/_build/html/_static/bootstrap-3.3.4/fonts/glyphicons-halflings-regular.svg +287 -287
  19. data/documentation/_build/html/_static/bootstrap-3.3.4/js/bootstrap.js +2317 -2317
  20. data/documentation/_build/html/_static/bootstrap-3.3.4/js/bootstrap.min.js +6 -6
  21. data/documentation/_build/html/_static/bootstrap-3.3.4/js/npm.js +12 -12
  22. data/documentation/_build/html/_static/bootstrap-sphinx.css +186 -186
  23. data/documentation/_build/html/_static/bootstrap-sphinx.js +161 -161
  24. data/documentation/_build/html/_static/bootswatch-2.3.2/amelia/bootstrap.min.css +9 -9
  25. data/documentation/_build/html/_static/bootswatch-2.3.2/cerulean/bootstrap.min.css +9 -9
  26. data/documentation/_build/html/_static/bootswatch-2.3.2/cosmo/bootstrap.min.css +9 -9
  27. data/documentation/_build/html/_static/bootswatch-2.3.2/cyborg/bootstrap.min.css +9 -9
  28. data/documentation/_build/html/_static/bootswatch-2.3.2/flatly/bootstrap.min.css +9 -9
  29. data/documentation/_build/html/_static/bootswatch-2.3.2/journal/bootstrap.min.css +9 -9
  30. data/documentation/_build/html/_static/bootswatch-2.3.2/readable/bootstrap.min.css +9 -9
  31. data/documentation/_build/html/_static/bootswatch-2.3.2/simplex/bootstrap.min.css +9 -9
  32. data/documentation/_build/html/_static/bootswatch-2.3.2/slate/bootstrap.min.css +9 -9
  33. data/documentation/_build/html/_static/bootswatch-2.3.2/spacelab/bootstrap.min.css +9 -9
  34. data/documentation/_build/html/_static/bootswatch-2.3.2/spruce/bootstrap.min.css +9 -9
  35. data/documentation/_build/html/_static/bootswatch-2.3.2/superhero/bootstrap.min.css +9 -9
  36. data/documentation/_build/html/_static/bootswatch-2.3.2/united/bootstrap.min.css +9 -9
  37. data/documentation/_build/html/_static/bootswatch-3.3.4/cerulean/bootstrap.min.css +6 -6
  38. data/documentation/_build/html/_static/bootswatch-3.3.4/cosmo/bootstrap.min.css +6 -6
  39. data/documentation/_build/html/_static/bootswatch-3.3.4/custom/bootstrap.min.css +6 -6
  40. data/documentation/_build/html/_static/bootswatch-3.3.4/cyborg/bootstrap.min.css +6 -6
  41. data/documentation/_build/html/_static/bootswatch-3.3.4/darkly/bootstrap.min.css +6 -6
  42. data/documentation/_build/html/_static/bootswatch-3.3.4/flatly/bootstrap.min.css +6 -6
  43. data/documentation/_build/html/_static/bootswatch-3.3.4/fonts/glyphicons-halflings-regular.svg +287 -287
  44. data/documentation/_build/html/_static/bootswatch-3.3.4/journal/bootstrap.min.css +6 -6
  45. data/documentation/_build/html/_static/bootswatch-3.3.4/lumen/bootstrap.min.css +6 -6
  46. data/documentation/_build/html/_static/bootswatch-3.3.4/paper/bootstrap.min.css +6 -6
  47. data/documentation/_build/html/_static/bootswatch-3.3.4/readable/bootstrap.min.css +6 -6
  48. data/documentation/_build/html/_static/bootswatch-3.3.4/sandstone/bootstrap.min.css +6 -6
  49. data/documentation/_build/html/_static/bootswatch-3.3.4/simplex/bootstrap.min.css +6 -6
  50. data/documentation/_build/html/_static/bootswatch-3.3.4/slate/bootstrap.min.css +6 -6
  51. data/documentation/_build/html/_static/bootswatch-3.3.4/spacelab/bootstrap.min.css +6 -6
  52. data/documentation/_build/html/_static/bootswatch-3.3.4/superhero/bootstrap.min.css +6 -6
  53. data/documentation/_build/html/_static/bootswatch-3.3.4/united/bootstrap.min.css +6 -6
  54. data/documentation/_build/html/_static/bootswatch-3.3.4/yeti/bootstrap.min.css +6 -6
  55. data/documentation/_build/html/_static/doctools.js +263 -263
  56. data/documentation/_build/html/_static/jquery-1.11.1.js +10308 -10308
  57. data/documentation/_build/html/_static/jquery.js +4 -4
  58. data/documentation/_build/html/_static/js/jquery-1.11.0.min.js +4 -4
  59. data/documentation/_build/html/_static/js/jquery-fix.js +1 -1
  60. data/documentation/_build/html/_static/searchtools.js +621 -621
  61. data/documentation/_build/html/_static/underscore-1.3.1.js +999 -999
  62. data/documentation/_build/html/_static/underscore.js +31 -31
  63. data/documentation/_build/html/_static/websupport.js +808 -808
  64. data/documentation/_build/html/changelog.html +944 -937
  65. data/documentation/_build/html/commandline/commandline.html +284 -284
  66. data/documentation/_build/html/concepts/concepts.html +186 -186
  67. data/documentation/_build/html/concepts/link_order.html +245 -245
  68. data/documentation/_build/html/concepts/the_main_project.html +260 -260
  69. data/documentation/_build/html/concepts/the_project_meta_file.html +288 -288
  70. data/documentation/_build/html/genindex.html +152 -152
  71. data/documentation/_build/html/ide/eclipse/eclipse.html +186 -186
  72. data/documentation/_build/html/ide/eclipse/how_to_convert_existing_cdt_workspace.html +208 -208
  73. data/documentation/_build/html/ide/eclipse/how_to_create_a_new_project_in_eclipse.html +191 -191
  74. data/documentation/_build/html/ide/eclipse/how_to_create_a_workspace_in_eclipse.html +198 -198
  75. data/documentation/_build/html/ide/eclipse/how_to_debug_in_eclipse.html +198 -198
  76. data/documentation/_build/html/ide/eclipse/how_to_install_eclipse_plugin.html +196 -196
  77. data/documentation/_build/html/ide/eclipse/how_to_use_bake_in_eclipse.html +256 -256
  78. data/documentation/_build/html/ide/ide_integrations.html +183 -183
  79. data/documentation/_build/html/ide/vs/how_to_create_vs_projects.html +171 -171
  80. data/documentation/_build/html/ide/vs/how_to_debug_in_vs.html +185 -185
  81. data/documentation/_build/html/ide/vs/how_to_used_bake_in_vs.html +190 -190
  82. data/documentation/_build/html/ide/vs/vs.html +170 -170
  83. data/documentation/_build/html/ide/vs/vs_install.html +202 -202
  84. data/documentation/_build/html/index.html +241 -241
  85. data/documentation/_build/html/install/install_bake.html +279 -279
  86. data/documentation/_build/html/internal.html +217 -217
  87. data/documentation/_build/html/known_issues.html +175 -175
  88. data/documentation/_build/html/license.html +236 -236
  89. data/documentation/_build/html/performance/performance.html +373 -373
  90. data/documentation/_build/html/quickstart/quickstart.html +236 -236
  91. data/documentation/_build/html/search.html +174 -174
  92. data/documentation/_build/html/searchindex.js +1 -1
  93. data/documentation/_build/html/syntax/adapt_configs.html +286 -286
  94. data/documentation/_build/html/syntax/derive_configs.html +247 -247
  95. data/documentation/_build/html/syntax/project_meta_syntax.html +893 -893
  96. data/documentation/_build/html/syntax/syntax.html +189 -189
  97. data/documentation/_build/html/syntax/variable_substitutions.html +378 -378
  98. data/documentation/_build/html/tips_and_tricks/bundle.html +180 -180
  99. data/documentation/_build/html/tips_and_tricks/how_to_use_bake_with_cygwin.html +214 -203
  100. data/documentation/_build/html/tips_and_tricks/static_code_analysis.html +284 -284
  101. data/documentation/_build/html/tips_and_tricks/the_bakery.html +405 -405
  102. data/documentation/_build/html/tips_and_tricks/the_clang.html +201 -201
  103. data/documentation/_build/html/tips_and_tricks/tips_and_tricks.html +197 -197
  104. data/documentation/_build/html/why_bake/why_bake.html +241 -241
  105. data/lib/bake/subst.rb +40 -40
  106. data/lib/bake/toolchain/diab.rb +53 -53
  107. data/lib/bake/toolchain/gcc.rb +48 -48
  108. data/lib/bake/toolchain/gcc_env.rb +52 -52
  109. data/lib/bake/toolchain/msvc.rb +57 -57
  110. data/lib/blocks/block.rb +78 -63
  111. data/lib/blocks/blockBase.rb +33 -33
  112. data/lib/common/version.rb +2 -2
  113. metadata +4 -38
  114. data/documentation/_build/html/_images/logo_conformant_1024.png +0 -0
  115. data/documentation/_build/html/_images/logo_conformant_48.png +0 -0
  116. data/documentation/_build/html/_sources/concepts/build_hierarchy.txt +0 -34
  117. data/documentation/_build/html/_static/agogo.css +0 -509
  118. data/documentation/_build/html/_static/background_b01.png +0 -0
  119. data/documentation/_build/html/_static/bgfooter.png +0 -0
  120. data/documentation/_build/html/_static/bgtop.png +0 -0
  121. data/documentation/_build/html/_static/bizstyle.css +0 -490
  122. data/documentation/_build/html/_static/bizstyle.js +0 -41
  123. data/documentation/_build/html/_static/css/badge_only.css +0 -2
  124. data/documentation/_build/html/_static/css/theme.css +0 -5
  125. data/documentation/_build/html/_static/css3-mediaqueries.js +0 -1
  126. data/documentation/_build/html/_static/css3-mediaqueries_src.js +0 -1104
  127. data/documentation/_build/html/_static/debugEclipse/app.png +0 -0
  128. data/documentation/_build/html/_static/debugEclipse/debug.png +0 -0
  129. data/documentation/_build/html/_static/debugEclipse/flag.png +0 -0
  130. data/documentation/_build/html/_static/debugEclipse/map.png +0 -0
  131. data/documentation/_build/html/_static/debugEclipse/path.png +0 -0
  132. data/documentation/_build/html/_static/fonts/Inconsolata-Bold.ttf +0 -0
  133. data/documentation/_build/html/_static/fonts/Inconsolata.ttf +0 -0
  134. data/documentation/_build/html/_static/fonts/Lato-Bold.ttf +0 -0
  135. data/documentation/_build/html/_static/fonts/Lato-Regular.ttf +0 -0
  136. data/documentation/_build/html/_static/fonts/RobotoSlab-Bold.ttf +0 -0
  137. data/documentation/_build/html/_static/fonts/RobotoSlab-Regular.ttf +0 -0
  138. data/documentation/_build/html/_static/fonts/fontawesome-webfont.eot +0 -0
  139. data/documentation/_build/html/_static/fonts/fontawesome-webfont.svg +0 -414
  140. data/documentation/_build/html/_static/fonts/fontawesome-webfont.ttf +0 -0
  141. data/documentation/_build/html/_static/fonts/fontawesome-webfont.woff +0 -0
  142. data/documentation/_build/html/_static/js/modernizr.min.js +0 -4
  143. data/documentation/_build/html/_static/js/theme.js +0 -113
  144. data/documentation/_build/html/_static/logo_conformant_1024.png +0 -0
  145. data/documentation/_build/html/_static/logo_conformant_24.png +0 -0
  146. data/documentation/_build/html/_static/logo_conformant_256.png +0 -0
  147. data/documentation/_build/html/concepts/build_hierarchy.html +0 -205
@@ -1,31 +1,31 @@
1
- // Underscore.js 1.3.1
2
- // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
3
- // Underscore is freely distributable under the MIT license.
4
- // Portions of Underscore are inspired or borrowed from Prototype,
5
- // Oliver Steele's Functional, and John Resig's Micro-Templating.
6
- // For all details and documentation:
7
- // http://documentcloud.github.com/underscore
8
- (function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
9
- c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,
10
- h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each=
11
- b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===n)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===n)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(x&&a.map===x)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==
12
- null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=
13
- function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e=
14
- e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
15
- function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&(e={value:a,computed:b})});
16
- return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){f==0?b[0]=a:(d=Math.floor(Math.random()*(f+1)),b[f]=b[d],b[d]=a)});return b};b.sortBy=function(a,c,d){return b.pluck(b.map(a,function(a,b,g){return{value:a,criteria:c.call(d,a,b,g)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,
17
- c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:a.toArray?a.toArray():b.isArray(a)?i.call(a):b.isArguments(a)?i.call(a):b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=b.head=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=
18
- b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,e=[];b.reduce(d,function(d,g,h){if(0==h||(c===true?b.last(d)!=g:!b.include(d,g)))d[d.length]=g,e[e.length]=a[h];return d},[]);
19
- return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,
20
- d){if(a==null)return-1;var e;if(d)return d=b.sortedIndex(a,c),a[d]===c?d:-1;if(p&&a.indexOf===p)return a.indexOf(c);for(d=0,e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(D&&a.lastIndexOf===D)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){arguments.length<=1&&(b=a||0,a=0);for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;)g[f++]=a,a+=d;return g};
21
- var F=function(){};b.bind=function(a,c){var d,e;if(a.bind===s&&s)return s.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));F.prototype=a.prototype;var b=new F,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,
22
- c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(a,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i=b.debounce(function(){h=g=false},c);return function(){d=this;e=arguments;var b;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);i()},c));g?h=true:
23
- a.apply(d,e);i();g=true}};b.debounce=function(a,b){var d;return function(){var e=this,f=arguments;clearTimeout(d);d=setTimeout(function(){d=null;a.apply(e,f)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};
24
- b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments,
25
- 1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};
26
- b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};
27
- b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};b.mixin=function(a){j(b.functions(a),
28
- function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+
29
- u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]=
30
- function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=
31
- true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);
1
+ // Underscore.js 1.3.1
2
+ // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
3
+ // Underscore is freely distributable under the MIT license.
4
+ // Portions of Underscore are inspired or borrowed from Prototype,
5
+ // Oliver Steele's Functional, and John Resig's Micro-Templating.
6
+ // For all details and documentation:
7
+ // http://documentcloud.github.com/underscore
8
+ (function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
9
+ c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,
10
+ h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each=
11
+ b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===n)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===n)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(x&&a.map===x)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==
12
+ null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=
13
+ function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e=
14
+ e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
15
+ function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&(e={value:a,computed:b})});
16
+ return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){f==0?b[0]=a:(d=Math.floor(Math.random()*(f+1)),b[f]=b[d],b[d]=a)});return b};b.sortBy=function(a,c,d){return b.pluck(b.map(a,function(a,b,g){return{value:a,criteria:c.call(d,a,b,g)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,
17
+ c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:a.toArray?a.toArray():b.isArray(a)?i.call(a):b.isArguments(a)?i.call(a):b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=b.head=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=
18
+ b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,e=[];b.reduce(d,function(d,g,h){if(0==h||(c===true?b.last(d)!=g:!b.include(d,g)))d[d.length]=g,e[e.length]=a[h];return d},[]);
19
+ return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,
20
+ d){if(a==null)return-1;var e;if(d)return d=b.sortedIndex(a,c),a[d]===c?d:-1;if(p&&a.indexOf===p)return a.indexOf(c);for(d=0,e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(D&&a.lastIndexOf===D)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){arguments.length<=1&&(b=a||0,a=0);for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;)g[f++]=a,a+=d;return g};
21
+ var F=function(){};b.bind=function(a,c){var d,e;if(a.bind===s&&s)return s.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));F.prototype=a.prototype;var b=new F,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,
22
+ c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(a,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i=b.debounce(function(){h=g=false},c);return function(){d=this;e=arguments;var b;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);i()},c));g?h=true:
23
+ a.apply(d,e);i();g=true}};b.debounce=function(a,b){var d;return function(){var e=this,f=arguments;clearTimeout(d);d=setTimeout(function(){d=null;a.apply(e,f)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};
24
+ b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments,
25
+ 1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};
26
+ b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};
27
+ b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};b.mixin=function(a){j(b.functions(a),
28
+ function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+
29
+ u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]=
30
+ function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=
31
+ true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);
@@ -1,808 +1,808 @@
1
- /*
2
- * websupport.js
3
- * ~~~~~~~~~~~~~
4
- *
5
- * sphinx.websupport utilties for all documentation.
6
- *
7
- * :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
8
- * :license: BSD, see LICENSE for details.
9
- *
10
- */
11
-
12
- (function($) {
13
- $.fn.autogrow = function() {
14
- return this.each(function() {
15
- var textarea = this;
16
-
17
- $.fn.autogrow.resize(textarea);
18
-
19
- $(textarea)
20
- .focus(function() {
21
- textarea.interval = setInterval(function() {
22
- $.fn.autogrow.resize(textarea);
23
- }, 500);
24
- })
25
- .blur(function() {
26
- clearInterval(textarea.interval);
27
- });
28
- });
29
- };
30
-
31
- $.fn.autogrow.resize = function(textarea) {
32
- var lineHeight = parseInt($(textarea).css('line-height'), 10);
33
- var lines = textarea.value.split('\n');
34
- var columns = textarea.cols;
35
- var lineCount = 0;
36
- $.each(lines, function() {
37
- lineCount += Math.ceil(this.length / columns) || 1;
38
- });
39
- var height = lineHeight * (lineCount + 1);
40
- $(textarea).css('height', height);
41
- };
42
- })(jQuery);
43
-
44
- (function($) {
45
- var comp, by;
46
-
47
- function init() {
48
- initEvents();
49
- initComparator();
50
- }
51
-
52
- function initEvents() {
53
- $(document).on("click", 'a.comment-close', function(event) {
54
- event.preventDefault();
55
- hide($(this).attr('id').substring(2));
56
- });
57
- $(document).on("click", 'a.vote', function(event) {
58
- event.preventDefault();
59
- handleVote($(this));
60
- });
61
- $(document).on("click", 'a.reply', function(event) {
62
- event.preventDefault();
63
- openReply($(this).attr('id').substring(2));
64
- });
65
- $(document).on("click", 'a.close-reply', function(event) {
66
- event.preventDefault();
67
- closeReply($(this).attr('id').substring(2));
68
- });
69
- $(document).on("click", 'a.sort-option', function(event) {
70
- event.preventDefault();
71
- handleReSort($(this));
72
- });
73
- $(document).on("click", 'a.show-proposal', function(event) {
74
- event.preventDefault();
75
- showProposal($(this).attr('id').substring(2));
76
- });
77
- $(document).on("click", 'a.hide-proposal', function(event) {
78
- event.preventDefault();
79
- hideProposal($(this).attr('id').substring(2));
80
- });
81
- $(document).on("click", 'a.show-propose-change', function(event) {
82
- event.preventDefault();
83
- showProposeChange($(this).attr('id').substring(2));
84
- });
85
- $(document).on("click", 'a.hide-propose-change', function(event) {
86
- event.preventDefault();
87
- hideProposeChange($(this).attr('id').substring(2));
88
- });
89
- $(document).on("click", 'a.accept-comment', function(event) {
90
- event.preventDefault();
91
- acceptComment($(this).attr('id').substring(2));
92
- });
93
- $(document).on("click", 'a.delete-comment', function(event) {
94
- event.preventDefault();
95
- deleteComment($(this).attr('id').substring(2));
96
- });
97
- $(document).on("click", 'a.comment-markup', function(event) {
98
- event.preventDefault();
99
- toggleCommentMarkupBox($(this).attr('id').substring(2));
100
- });
101
- }
102
-
103
- /**
104
- * Set comp, which is a comparator function used for sorting and
105
- * inserting comments into the list.
106
- */
107
- function setComparator() {
108
- // If the first three letters are "asc", sort in ascending order
109
- // and remove the prefix.
110
- if (by.substring(0,3) == 'asc') {
111
- var i = by.substring(3);
112
- comp = function(a, b) { return a[i] - b[i]; };
113
- } else {
114
- // Otherwise sort in descending order.
115
- comp = function(a, b) { return b[by] - a[by]; };
116
- }
117
-
118
- // Reset link styles and format the selected sort option.
119
- $('a.sel').attr('href', '#').removeClass('sel');
120
- $('a.by' + by).removeAttr('href').addClass('sel');
121
- }
122
-
123
- /**
124
- * Create a comp function. If the user has preferences stored in
125
- * the sortBy cookie, use those, otherwise use the default.
126
- */
127
- function initComparator() {
128
- by = 'rating'; // Default to sort by rating.
129
- // If the sortBy cookie is set, use that instead.
130
- if (document.cookie.length > 0) {
131
- var start = document.cookie.indexOf('sortBy=');
132
- if (start != -1) {
133
- start = start + 7;
134
- var end = document.cookie.indexOf(";", start);
135
- if (end == -1) {
136
- end = document.cookie.length;
137
- by = unescape(document.cookie.substring(start, end));
138
- }
139
- }
140
- }
141
- setComparator();
142
- }
143
-
144
- /**
145
- * Show a comment div.
146
- */
147
- function show(id) {
148
- $('#ao' + id).hide();
149
- $('#ah' + id).show();
150
- var context = $.extend({id: id}, opts);
151
- var popup = $(renderTemplate(popupTemplate, context)).hide();
152
- popup.find('textarea[name="proposal"]').hide();
153
- popup.find('a.by' + by).addClass('sel');
154
- var form = popup.find('#cf' + id);
155
- form.submit(function(event) {
156
- event.preventDefault();
157
- addComment(form);
158
- });
159
- $('#s' + id).after(popup);
160
- popup.slideDown('fast', function() {
161
- getComments(id);
162
- });
163
- }
164
-
165
- /**
166
- * Hide a comment div.
167
- */
168
- function hide(id) {
169
- $('#ah' + id).hide();
170
- $('#ao' + id).show();
171
- var div = $('#sc' + id);
172
- div.slideUp('fast', function() {
173
- div.remove();
174
- });
175
- }
176
-
177
- /**
178
- * Perform an ajax request to get comments for a node
179
- * and insert the comments into the comments tree.
180
- */
181
- function getComments(id) {
182
- $.ajax({
183
- type: 'GET',
184
- url: opts.getCommentsURL,
185
- data: {node: id},
186
- success: function(data, textStatus, request) {
187
- var ul = $('#cl' + id);
188
- var speed = 100;
189
- $('#cf' + id)
190
- .find('textarea[name="proposal"]')
191
- .data('source', data.source);
192
-
193
- if (data.comments.length === 0) {
194
- ul.html('<li>No comments yet.</li>');
195
- ul.data('empty', true);
196
- } else {
197
- // If there are comments, sort them and put them in the list.
198
- var comments = sortComments(data.comments);
199
- speed = data.comments.length * 100;
200
- appendComments(comments, ul);
201
- ul.data('empty', false);
202
- }
203
- $('#cn' + id).slideUp(speed + 200);
204
- ul.slideDown(speed);
205
- },
206
- error: function(request, textStatus, error) {
207
- showError('Oops, there was a problem retrieving the comments.');
208
- },
209
- dataType: 'json'
210
- });
211
- }
212
-
213
- /**
214
- * Add a comment via ajax and insert the comment into the comment tree.
215
- */
216
- function addComment(form) {
217
- var node_id = form.find('input[name="node"]').val();
218
- var parent_id = form.find('input[name="parent"]').val();
219
- var text = form.find('textarea[name="comment"]').val();
220
- var proposal = form.find('textarea[name="proposal"]').val();
221
-
222
- if (text == '') {
223
- showError('Please enter a comment.');
224
- return;
225
- }
226
-
227
- // Disable the form that is being submitted.
228
- form.find('textarea,input').attr('disabled', 'disabled');
229
-
230
- // Send the comment to the server.
231
- $.ajax({
232
- type: "POST",
233
- url: opts.addCommentURL,
234
- dataType: 'json',
235
- data: {
236
- node: node_id,
237
- parent: parent_id,
238
- text: text,
239
- proposal: proposal
240
- },
241
- success: function(data, textStatus, error) {
242
- // Reset the form.
243
- if (node_id) {
244
- hideProposeChange(node_id);
245
- }
246
- form.find('textarea')
247
- .val('')
248
- .add(form.find('input'))
249
- .removeAttr('disabled');
250
- var ul = $('#cl' + (node_id || parent_id));
251
- if (ul.data('empty')) {
252
- $(ul).empty();
253
- ul.data('empty', false);
254
- }
255
- insertComment(data.comment);
256
- var ao = $('#ao' + node_id);
257
- ao.find('img').attr({'src': opts.commentBrightImage});
258
- if (node_id) {
259
- // if this was a "root" comment, remove the commenting box
260
- // (the user can get it back by reopening the comment popup)
261
- $('#ca' + node_id).slideUp();
262
- }
263
- },
264
- error: function(request, textStatus, error) {
265
- form.find('textarea,input').removeAttr('disabled');
266
- showError('Oops, there was a problem adding the comment.');
267
- }
268
- });
269
- }
270
-
271
- /**
272
- * Recursively append comments to the main comment list and children
273
- * lists, creating the comment tree.
274
- */
275
- function appendComments(comments, ul) {
276
- $.each(comments, function() {
277
- var div = createCommentDiv(this);
278
- ul.append($(document.createElement('li')).html(div));
279
- appendComments(this.children, div.find('ul.comment-children'));
280
- // To avoid stagnating data, don't store the comments children in data.
281
- this.children = null;
282
- div.data('comment', this);
283
- });
284
- }
285
-
286
- /**
287
- * After adding a new comment, it must be inserted in the correct
288
- * location in the comment tree.
289
- */
290
- function insertComment(comment) {
291
- var div = createCommentDiv(comment);
292
-
293
- // To avoid stagnating data, don't store the comments children in data.
294
- comment.children = null;
295
- div.data('comment', comment);
296
-
297
- var ul = $('#cl' + (comment.node || comment.parent));
298
- var siblings = getChildren(ul);
299
-
300
- var li = $(document.createElement('li'));
301
- li.hide();
302
-
303
- // Determine where in the parents children list to insert this comment.
304
- for(i=0; i < siblings.length; i++) {
305
- if (comp(comment, siblings[i]) <= 0) {
306
- $('#cd' + siblings[i].id)
307
- .parent()
308
- .before(li.html(div));
309
- li.slideDown('fast');
310
- return;
311
- }
312
- }
313
-
314
- // If we get here, this comment rates lower than all the others,
315
- // or it is the only comment in the list.
316
- ul.append(li.html(div));
317
- li.slideDown('fast');
318
- }
319
-
320
- function acceptComment(id) {
321
- $.ajax({
322
- type: 'POST',
323
- url: opts.acceptCommentURL,
324
- data: {id: id},
325
- success: function(data, textStatus, request) {
326
- $('#cm' + id).fadeOut('fast');
327
- $('#cd' + id).removeClass('moderate');
328
- },
329
- error: function(request, textStatus, error) {
330
- showError('Oops, there was a problem accepting the comment.');
331
- }
332
- });
333
- }
334
-
335
- function deleteComment(id) {
336
- $.ajax({
337
- type: 'POST',
338
- url: opts.deleteCommentURL,
339
- data: {id: id},
340
- success: function(data, textStatus, request) {
341
- var div = $('#cd' + id);
342
- if (data == 'delete') {
343
- // Moderator mode: remove the comment and all children immediately
344
- div.slideUp('fast', function() {
345
- div.remove();
346
- });
347
- return;
348
- }
349
- // User mode: only mark the comment as deleted
350
- div
351
- .find('span.user-id:first')
352
- .text('[deleted]').end()
353
- .find('div.comment-text:first')
354
- .text('[deleted]').end()
355
- .find('#cm' + id + ', #dc' + id + ', #ac' + id + ', #rc' + id +
356
- ', #sp' + id + ', #hp' + id + ', #cr' + id + ', #rl' + id)
357
- .remove();
358
- var comment = div.data('comment');
359
- comment.username = '[deleted]';
360
- comment.text = '[deleted]';
361
- div.data('comment', comment);
362
- },
363
- error: function(request, textStatus, error) {
364
- showError('Oops, there was a problem deleting the comment.');
365
- }
366
- });
367
- }
368
-
369
- function showProposal(id) {
370
- $('#sp' + id).hide();
371
- $('#hp' + id).show();
372
- $('#pr' + id).slideDown('fast');
373
- }
374
-
375
- function hideProposal(id) {
376
- $('#hp' + id).hide();
377
- $('#sp' + id).show();
378
- $('#pr' + id).slideUp('fast');
379
- }
380
-
381
- function showProposeChange(id) {
382
- $('#pc' + id).hide();
383
- $('#hc' + id).show();
384
- var textarea = $('#pt' + id);
385
- textarea.val(textarea.data('source'));
386
- $.fn.autogrow.resize(textarea[0]);
387
- textarea.slideDown('fast');
388
- }
389
-
390
- function hideProposeChange(id) {
391
- $('#hc' + id).hide();
392
- $('#pc' + id).show();
393
- var textarea = $('#pt' + id);
394
- textarea.val('').removeAttr('disabled');
395
- textarea.slideUp('fast');
396
- }
397
-
398
- function toggleCommentMarkupBox(id) {
399
- $('#mb' + id).toggle();
400
- }
401
-
402
- /** Handle when the user clicks on a sort by link. */
403
- function handleReSort(link) {
404
- var classes = link.attr('class').split(/\s+/);
405
- for (var i=0; i<classes.length; i++) {
406
- if (classes[i] != 'sort-option') {
407
- by = classes[i].substring(2);
408
- }
409
- }
410
- setComparator();
411
- // Save/update the sortBy cookie.
412
- var expiration = new Date();
413
- expiration.setDate(expiration.getDate() + 365);
414
- document.cookie= 'sortBy=' + escape(by) +
415
- ';expires=' + expiration.toUTCString();
416
- $('ul.comment-ul').each(function(index, ul) {
417
- var comments = getChildren($(ul), true);
418
- comments = sortComments(comments);
419
- appendComments(comments, $(ul).empty());
420
- });
421
- }
422
-
423
- /**
424
- * Function to process a vote when a user clicks an arrow.
425
- */
426
- function handleVote(link) {
427
- if (!opts.voting) {
428
- showError("You'll need to login to vote.");
429
- return;
430
- }
431
-
432
- var id = link.attr('id');
433
- if (!id) {
434
- // Didn't click on one of the voting arrows.
435
- return;
436
- }
437
- // If it is an unvote, the new vote value is 0,
438
- // Otherwise it's 1 for an upvote, or -1 for a downvote.
439
- var value = 0;
440
- if (id.charAt(1) != 'u') {
441
- value = id.charAt(0) == 'u' ? 1 : -1;
442
- }
443
- // The data to be sent to the server.
444
- var d = {
445
- comment_id: id.substring(2),
446
- value: value
447
- };
448
-
449
- // Swap the vote and unvote links.
450
- link.hide();
451
- $('#' + id.charAt(0) + (id.charAt(1) == 'u' ? 'v' : 'u') + d.comment_id)
452
- .show();
453
-
454
- // The div the comment is displayed in.
455
- var div = $('div#cd' + d.comment_id);
456
- var data = div.data('comment');
457
-
458
- // If this is not an unvote, and the other vote arrow has
459
- // already been pressed, unpress it.
460
- if ((d.value !== 0) && (data.vote === d.value * -1)) {
461
- $('#' + (d.value == 1 ? 'd' : 'u') + 'u' + d.comment_id).hide();
462
- $('#' + (d.value == 1 ? 'd' : 'u') + 'v' + d.comment_id).show();
463
- }
464
-
465
- // Update the comments rating in the local data.
466
- data.rating += (data.vote === 0) ? d.value : (d.value - data.vote);
467
- data.vote = d.value;
468
- div.data('comment', data);
469
-
470
- // Change the rating text.
471
- div.find('.rating:first')
472
- .text(data.rating + ' point' + (data.rating == 1 ? '' : 's'));
473
-
474
- // Send the vote information to the server.
475
- $.ajax({
476
- type: "POST",
477
- url: opts.processVoteURL,
478
- data: d,
479
- error: function(request, textStatus, error) {
480
- showError('Oops, there was a problem casting that vote.');
481
- }
482
- });
483
- }
484
-
485
- /**
486
- * Open a reply form used to reply to an existing comment.
487
- */
488
- function openReply(id) {
489
- // Swap out the reply link for the hide link
490
- $('#rl' + id).hide();
491
- $('#cr' + id).show();
492
-
493
- // Add the reply li to the children ul.
494
- var div = $(renderTemplate(replyTemplate, {id: id})).hide();
495
- $('#cl' + id)
496
- .prepend(div)
497
- // Setup the submit handler for the reply form.
498
- .find('#rf' + id)
499
- .submit(function(event) {
500
- event.preventDefault();
501
- addComment($('#rf' + id));
502
- closeReply(id);
503
- })
504
- .find('input[type=button]')
505
- .click(function() {
506
- closeReply(id);
507
- });
508
- div.slideDown('fast', function() {
509
- $('#rf' + id).find('textarea').focus();
510
- });
511
- }
512
-
513
- /**
514
- * Close the reply form opened with openReply.
515
- */
516
- function closeReply(id) {
517
- // Remove the reply div from the DOM.
518
- $('#rd' + id).slideUp('fast', function() {
519
- $(this).remove();
520
- });
521
-
522
- // Swap out the hide link for the reply link
523
- $('#cr' + id).hide();
524
- $('#rl' + id).show();
525
- }
526
-
527
- /**
528
- * Recursively sort a tree of comments using the comp comparator.
529
- */
530
- function sortComments(comments) {
531
- comments.sort(comp);
532
- $.each(comments, function() {
533
- this.children = sortComments(this.children);
534
- });
535
- return comments;
536
- }
537
-
538
- /**
539
- * Get the children comments from a ul. If recursive is true,
540
- * recursively include childrens' children.
541
- */
542
- function getChildren(ul, recursive) {
543
- var children = [];
544
- ul.children().children("[id^='cd']")
545
- .each(function() {
546
- var comment = $(this).data('comment');
547
- if (recursive)
548
- comment.children = getChildren($(this).find('#cl' + comment.id), true);
549
- children.push(comment);
550
- });
551
- return children;
552
- }
553
-
554
- /** Create a div to display a comment in. */
555
- function createCommentDiv(comment) {
556
- if (!comment.displayed && !opts.moderator) {
557
- return $('<div class="moderate">Thank you! Your comment will show up '
558
- + 'once it is has been approved by a moderator.</div>');
559
- }
560
- // Prettify the comment rating.
561
- comment.pretty_rating = comment.rating + ' point' +
562
- (comment.rating == 1 ? '' : 's');
563
- // Make a class (for displaying not yet moderated comments differently)
564
- comment.css_class = comment.displayed ? '' : ' moderate';
565
- // Create a div for this comment.
566
- var context = $.extend({}, opts, comment);
567
- var div = $(renderTemplate(commentTemplate, context));
568
-
569
- // If the user has voted on this comment, highlight the correct arrow.
570
- if (comment.vote) {
571
- var direction = (comment.vote == 1) ? 'u' : 'd';
572
- div.find('#' + direction + 'v' + comment.id).hide();
573
- div.find('#' + direction + 'u' + comment.id).show();
574
- }
575
-
576
- if (opts.moderator || comment.text != '[deleted]') {
577
- div.find('a.reply').show();
578
- if (comment.proposal_diff)
579
- div.find('#sp' + comment.id).show();
580
- if (opts.moderator && !comment.displayed)
581
- div.find('#cm' + comment.id).show();
582
- if (opts.moderator || (opts.username == comment.username))
583
- div.find('#dc' + comment.id).show();
584
- }
585
- return div;
586
- }
587
-
588
- /**
589
- * A simple template renderer. Placeholders such as <%id%> are replaced
590
- * by context['id'] with items being escaped. Placeholders such as <#id#>
591
- * are not escaped.
592
- */
593
- function renderTemplate(template, context) {
594
- var esc = $(document.createElement('div'));
595
-
596
- function handle(ph, escape) {
597
- var cur = context;
598
- $.each(ph.split('.'), function() {
599
- cur = cur[this];
600
- });
601
- return escape ? esc.text(cur || "").html() : cur;
602
- }
603
-
604
- return template.replace(/<([%#])([\w\.]*)\1>/g, function() {
605
- return handle(arguments[2], arguments[1] == '%' ? true : false);
606
- });
607
- }
608
-
609
- /** Flash an error message briefly. */
610
- function showError(message) {
611
- $(document.createElement('div')).attr({'class': 'popup-error'})
612
- .append($(document.createElement('div'))
613
- .attr({'class': 'error-message'}).text(message))
614
- .appendTo('body')
615
- .fadeIn("slow")
616
- .delay(2000)
617
- .fadeOut("slow");
618
- }
619
-
620
- /** Add a link the user uses to open the comments popup. */
621
- $.fn.comment = function() {
622
- return this.each(function() {
623
- var id = $(this).attr('id').substring(1);
624
- var count = COMMENT_METADATA[id];
625
- var title = count + ' comment' + (count == 1 ? '' : 's');
626
- var image = count > 0 ? opts.commentBrightImage : opts.commentImage;
627
- var addcls = count == 0 ? ' nocomment' : '';
628
- $(this)
629
- .append(
630
- $(document.createElement('a')).attr({
631
- href: '#',
632
- 'class': 'sphinx-comment-open' + addcls,
633
- id: 'ao' + id
634
- })
635
- .append($(document.createElement('img')).attr({
636
- src: image,
637
- alt: 'comment',
638
- title: title
639
- }))
640
- .click(function(event) {
641
- event.preventDefault();
642
- show($(this).attr('id').substring(2));
643
- })
644
- )
645
- .append(
646
- $(document.createElement('a')).attr({
647
- href: '#',
648
- 'class': 'sphinx-comment-close hidden',
649
- id: 'ah' + id
650
- })
651
- .append($(document.createElement('img')).attr({
652
- src: opts.closeCommentImage,
653
- alt: 'close',
654
- title: 'close'
655
- }))
656
- .click(function(event) {
657
- event.preventDefault();
658
- hide($(this).attr('id').substring(2));
659
- })
660
- );
661
- });
662
- };
663
-
664
- var opts = {
665
- processVoteURL: '/_process_vote',
666
- addCommentURL: '/_add_comment',
667
- getCommentsURL: '/_get_comments',
668
- acceptCommentURL: '/_accept_comment',
669
- deleteCommentURL: '/_delete_comment',
670
- commentImage: '/static/_static/comment.png',
671
- closeCommentImage: '/static/_static/comment-close.png',
672
- loadingImage: '/static/_static/ajax-loader.gif',
673
- commentBrightImage: '/static/_static/comment-bright.png',
674
- upArrow: '/static/_static/up.png',
675
- downArrow: '/static/_static/down.png',
676
- upArrowPressed: '/static/_static/up-pressed.png',
677
- downArrowPressed: '/static/_static/down-pressed.png',
678
- voting: false,
679
- moderator: false
680
- };
681
-
682
- if (typeof COMMENT_OPTIONS != "undefined") {
683
- opts = jQuery.extend(opts, COMMENT_OPTIONS);
684
- }
685
-
686
- var popupTemplate = '\
687
- <div class="sphinx-comments" id="sc<%id%>">\
688
- <p class="sort-options">\
689
- Sort by:\
690
- <a href="#" class="sort-option byrating">best rated</a>\
691
- <a href="#" class="sort-option byascage">newest</a>\
692
- <a href="#" class="sort-option byage">oldest</a>\
693
- </p>\
694
- <div class="comment-header">Comments</div>\
695
- <div class="comment-loading" id="cn<%id%>">\
696
- loading comments... <img src="<%loadingImage%>" alt="" /></div>\
697
- <ul id="cl<%id%>" class="comment-ul"></ul>\
698
- <div id="ca<%id%>">\
699
- <p class="add-a-comment">Add a comment\
700
- (<a href="#" class="comment-markup" id="ab<%id%>">markup</a>):</p>\
701
- <div class="comment-markup-box" id="mb<%id%>">\
702
- reStructured text markup: <i>*emph*</i>, <b>**strong**</b>, \
703
- <code>``code``</code>, \
704
- code blocks: <code>::</code> and an indented block after blank line</div>\
705
- <form method="post" id="cf<%id%>" class="comment-form" action="">\
706
- <textarea name="comment" cols="80"></textarea>\
707
- <p class="propose-button">\
708
- <a href="#" id="pc<%id%>" class="show-propose-change">\
709
- Propose a change &#9657;\
710
- </a>\
711
- <a href="#" id="hc<%id%>" class="hide-propose-change">\
712
- Propose a change &#9663;\
713
- </a>\
714
- </p>\
715
- <textarea name="proposal" id="pt<%id%>" cols="80"\
716
- spellcheck="false"></textarea>\
717
- <input type="submit" value="Add comment" />\
718
- <input type="hidden" name="node" value="<%id%>" />\
719
- <input type="hidden" name="parent" value="" />\
720
- </form>\
721
- </div>\
722
- </div>';
723
-
724
- var commentTemplate = '\
725
- <div id="cd<%id%>" class="sphinx-comment<%css_class%>">\
726
- <div class="vote">\
727
- <div class="arrow">\
728
- <a href="#" id="uv<%id%>" class="vote" title="vote up">\
729
- <img src="<%upArrow%>" />\
730
- </a>\
731
- <a href="#" id="uu<%id%>" class="un vote" title="vote up">\
732
- <img src="<%upArrowPressed%>" />\
733
- </a>\
734
- </div>\
735
- <div class="arrow">\
736
- <a href="#" id="dv<%id%>" class="vote" title="vote down">\
737
- <img src="<%downArrow%>" id="da<%id%>" />\
738
- </a>\
739
- <a href="#" id="du<%id%>" class="un vote" title="vote down">\
740
- <img src="<%downArrowPressed%>" />\
741
- </a>\
742
- </div>\
743
- </div>\
744
- <div class="comment-content">\
745
- <p class="tagline comment">\
746
- <span class="user-id"><%username%></span>\
747
- <span class="rating"><%pretty_rating%></span>\
748
- <span class="delta"><%time.delta%></span>\
749
- </p>\
750
- <div class="comment-text comment"><#text#></div>\
751
- <p class="comment-opts comment">\
752
- <a href="#" class="reply hidden" id="rl<%id%>">reply &#9657;</a>\
753
- <a href="#" class="close-reply" id="cr<%id%>">reply &#9663;</a>\
754
- <a href="#" id="sp<%id%>" class="show-proposal">proposal &#9657;</a>\
755
- <a href="#" id="hp<%id%>" class="hide-proposal">proposal &#9663;</a>\
756
- <a href="#" id="dc<%id%>" class="delete-comment hidden">delete</a>\
757
- <span id="cm<%id%>" class="moderation hidden">\
758
- <a href="#" id="ac<%id%>" class="accept-comment">accept</a>\
759
- </span>\
760
- </p>\
761
- <pre class="proposal" id="pr<%id%>">\
762
- <#proposal_diff#>\
763
- </pre>\
764
- <ul class="comment-children" id="cl<%id%>"></ul>\
765
- </div>\
766
- <div class="clearleft"></div>\
767
- </div>\
768
- </div>';
769
-
770
- var replyTemplate = '\
771
- <li>\
772
- <div class="reply-div" id="rd<%id%>">\
773
- <form id="rf<%id%>">\
774
- <textarea name="comment" cols="80"></textarea>\
775
- <input type="submit" value="Add reply" />\
776
- <input type="button" value="Cancel" />\
777
- <input type="hidden" name="parent" value="<%id%>" />\
778
- <input type="hidden" name="node" value="" />\
779
- </form>\
780
- </div>\
781
- </li>';
782
-
783
- $(document).ready(function() {
784
- init();
785
- });
786
- })(jQuery);
787
-
788
- $(document).ready(function() {
789
- // add comment anchors for all paragraphs that are commentable
790
- $('.sphinx-has-comment').comment();
791
-
792
- // highlight search words in search results
793
- $("div.context").each(function() {
794
- var params = $.getQueryParameters();
795
- var terms = (params.q) ? params.q[0].split(/\s+/) : [];
796
- var result = $(this);
797
- $.each(terms, function() {
798
- result.highlightText(this.toLowerCase(), 'highlighted');
799
- });
800
- });
801
-
802
- // directly open comment window if requested
803
- var anchor = document.location.hash;
804
- if (anchor.substring(0, 9) == '#comment-') {
805
- $('#ao' + anchor.substring(9)).click();
806
- document.location.hash = '#s' + anchor.substring(9);
807
- }
808
- });
1
+ /*
2
+ * websupport.js
3
+ * ~~~~~~~~~~~~~
4
+ *
5
+ * sphinx.websupport utilties for all documentation.
6
+ *
7
+ * :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
8
+ * :license: BSD, see LICENSE for details.
9
+ *
10
+ */
11
+
12
+ (function($) {
13
+ $.fn.autogrow = function() {
14
+ return this.each(function() {
15
+ var textarea = this;
16
+
17
+ $.fn.autogrow.resize(textarea);
18
+
19
+ $(textarea)
20
+ .focus(function() {
21
+ textarea.interval = setInterval(function() {
22
+ $.fn.autogrow.resize(textarea);
23
+ }, 500);
24
+ })
25
+ .blur(function() {
26
+ clearInterval(textarea.interval);
27
+ });
28
+ });
29
+ };
30
+
31
+ $.fn.autogrow.resize = function(textarea) {
32
+ var lineHeight = parseInt($(textarea).css('line-height'), 10);
33
+ var lines = textarea.value.split('\n');
34
+ var columns = textarea.cols;
35
+ var lineCount = 0;
36
+ $.each(lines, function() {
37
+ lineCount += Math.ceil(this.length / columns) || 1;
38
+ });
39
+ var height = lineHeight * (lineCount + 1);
40
+ $(textarea).css('height', height);
41
+ };
42
+ })(jQuery);
43
+
44
+ (function($) {
45
+ var comp, by;
46
+
47
+ function init() {
48
+ initEvents();
49
+ initComparator();
50
+ }
51
+
52
+ function initEvents() {
53
+ $(document).on("click", 'a.comment-close', function(event) {
54
+ event.preventDefault();
55
+ hide($(this).attr('id').substring(2));
56
+ });
57
+ $(document).on("click", 'a.vote', function(event) {
58
+ event.preventDefault();
59
+ handleVote($(this));
60
+ });
61
+ $(document).on("click", 'a.reply', function(event) {
62
+ event.preventDefault();
63
+ openReply($(this).attr('id').substring(2));
64
+ });
65
+ $(document).on("click", 'a.close-reply', function(event) {
66
+ event.preventDefault();
67
+ closeReply($(this).attr('id').substring(2));
68
+ });
69
+ $(document).on("click", 'a.sort-option', function(event) {
70
+ event.preventDefault();
71
+ handleReSort($(this));
72
+ });
73
+ $(document).on("click", 'a.show-proposal', function(event) {
74
+ event.preventDefault();
75
+ showProposal($(this).attr('id').substring(2));
76
+ });
77
+ $(document).on("click", 'a.hide-proposal', function(event) {
78
+ event.preventDefault();
79
+ hideProposal($(this).attr('id').substring(2));
80
+ });
81
+ $(document).on("click", 'a.show-propose-change', function(event) {
82
+ event.preventDefault();
83
+ showProposeChange($(this).attr('id').substring(2));
84
+ });
85
+ $(document).on("click", 'a.hide-propose-change', function(event) {
86
+ event.preventDefault();
87
+ hideProposeChange($(this).attr('id').substring(2));
88
+ });
89
+ $(document).on("click", 'a.accept-comment', function(event) {
90
+ event.preventDefault();
91
+ acceptComment($(this).attr('id').substring(2));
92
+ });
93
+ $(document).on("click", 'a.delete-comment', function(event) {
94
+ event.preventDefault();
95
+ deleteComment($(this).attr('id').substring(2));
96
+ });
97
+ $(document).on("click", 'a.comment-markup', function(event) {
98
+ event.preventDefault();
99
+ toggleCommentMarkupBox($(this).attr('id').substring(2));
100
+ });
101
+ }
102
+
103
+ /**
104
+ * Set comp, which is a comparator function used for sorting and
105
+ * inserting comments into the list.
106
+ */
107
+ function setComparator() {
108
+ // If the first three letters are "asc", sort in ascending order
109
+ // and remove the prefix.
110
+ if (by.substring(0,3) == 'asc') {
111
+ var i = by.substring(3);
112
+ comp = function(a, b) { return a[i] - b[i]; };
113
+ } else {
114
+ // Otherwise sort in descending order.
115
+ comp = function(a, b) { return b[by] - a[by]; };
116
+ }
117
+
118
+ // Reset link styles and format the selected sort option.
119
+ $('a.sel').attr('href', '#').removeClass('sel');
120
+ $('a.by' + by).removeAttr('href').addClass('sel');
121
+ }
122
+
123
+ /**
124
+ * Create a comp function. If the user has preferences stored in
125
+ * the sortBy cookie, use those, otherwise use the default.
126
+ */
127
+ function initComparator() {
128
+ by = 'rating'; // Default to sort by rating.
129
+ // If the sortBy cookie is set, use that instead.
130
+ if (document.cookie.length > 0) {
131
+ var start = document.cookie.indexOf('sortBy=');
132
+ if (start != -1) {
133
+ start = start + 7;
134
+ var end = document.cookie.indexOf(";", start);
135
+ if (end == -1) {
136
+ end = document.cookie.length;
137
+ by = unescape(document.cookie.substring(start, end));
138
+ }
139
+ }
140
+ }
141
+ setComparator();
142
+ }
143
+
144
+ /**
145
+ * Show a comment div.
146
+ */
147
+ function show(id) {
148
+ $('#ao' + id).hide();
149
+ $('#ah' + id).show();
150
+ var context = $.extend({id: id}, opts);
151
+ var popup = $(renderTemplate(popupTemplate, context)).hide();
152
+ popup.find('textarea[name="proposal"]').hide();
153
+ popup.find('a.by' + by).addClass('sel');
154
+ var form = popup.find('#cf' + id);
155
+ form.submit(function(event) {
156
+ event.preventDefault();
157
+ addComment(form);
158
+ });
159
+ $('#s' + id).after(popup);
160
+ popup.slideDown('fast', function() {
161
+ getComments(id);
162
+ });
163
+ }
164
+
165
+ /**
166
+ * Hide a comment div.
167
+ */
168
+ function hide(id) {
169
+ $('#ah' + id).hide();
170
+ $('#ao' + id).show();
171
+ var div = $('#sc' + id);
172
+ div.slideUp('fast', function() {
173
+ div.remove();
174
+ });
175
+ }
176
+
177
+ /**
178
+ * Perform an ajax request to get comments for a node
179
+ * and insert the comments into the comments tree.
180
+ */
181
+ function getComments(id) {
182
+ $.ajax({
183
+ type: 'GET',
184
+ url: opts.getCommentsURL,
185
+ data: {node: id},
186
+ success: function(data, textStatus, request) {
187
+ var ul = $('#cl' + id);
188
+ var speed = 100;
189
+ $('#cf' + id)
190
+ .find('textarea[name="proposal"]')
191
+ .data('source', data.source);
192
+
193
+ if (data.comments.length === 0) {
194
+ ul.html('<li>No comments yet.</li>');
195
+ ul.data('empty', true);
196
+ } else {
197
+ // If there are comments, sort them and put them in the list.
198
+ var comments = sortComments(data.comments);
199
+ speed = data.comments.length * 100;
200
+ appendComments(comments, ul);
201
+ ul.data('empty', false);
202
+ }
203
+ $('#cn' + id).slideUp(speed + 200);
204
+ ul.slideDown(speed);
205
+ },
206
+ error: function(request, textStatus, error) {
207
+ showError('Oops, there was a problem retrieving the comments.');
208
+ },
209
+ dataType: 'json'
210
+ });
211
+ }
212
+
213
+ /**
214
+ * Add a comment via ajax and insert the comment into the comment tree.
215
+ */
216
+ function addComment(form) {
217
+ var node_id = form.find('input[name="node"]').val();
218
+ var parent_id = form.find('input[name="parent"]').val();
219
+ var text = form.find('textarea[name="comment"]').val();
220
+ var proposal = form.find('textarea[name="proposal"]').val();
221
+
222
+ if (text == '') {
223
+ showError('Please enter a comment.');
224
+ return;
225
+ }
226
+
227
+ // Disable the form that is being submitted.
228
+ form.find('textarea,input').attr('disabled', 'disabled');
229
+
230
+ // Send the comment to the server.
231
+ $.ajax({
232
+ type: "POST",
233
+ url: opts.addCommentURL,
234
+ dataType: 'json',
235
+ data: {
236
+ node: node_id,
237
+ parent: parent_id,
238
+ text: text,
239
+ proposal: proposal
240
+ },
241
+ success: function(data, textStatus, error) {
242
+ // Reset the form.
243
+ if (node_id) {
244
+ hideProposeChange(node_id);
245
+ }
246
+ form.find('textarea')
247
+ .val('')
248
+ .add(form.find('input'))
249
+ .removeAttr('disabled');
250
+ var ul = $('#cl' + (node_id || parent_id));
251
+ if (ul.data('empty')) {
252
+ $(ul).empty();
253
+ ul.data('empty', false);
254
+ }
255
+ insertComment(data.comment);
256
+ var ao = $('#ao' + node_id);
257
+ ao.find('img').attr({'src': opts.commentBrightImage});
258
+ if (node_id) {
259
+ // if this was a "root" comment, remove the commenting box
260
+ // (the user can get it back by reopening the comment popup)
261
+ $('#ca' + node_id).slideUp();
262
+ }
263
+ },
264
+ error: function(request, textStatus, error) {
265
+ form.find('textarea,input').removeAttr('disabled');
266
+ showError('Oops, there was a problem adding the comment.');
267
+ }
268
+ });
269
+ }
270
+
271
+ /**
272
+ * Recursively append comments to the main comment list and children
273
+ * lists, creating the comment tree.
274
+ */
275
+ function appendComments(comments, ul) {
276
+ $.each(comments, function() {
277
+ var div = createCommentDiv(this);
278
+ ul.append($(document.createElement('li')).html(div));
279
+ appendComments(this.children, div.find('ul.comment-children'));
280
+ // To avoid stagnating data, don't store the comments children in data.
281
+ this.children = null;
282
+ div.data('comment', this);
283
+ });
284
+ }
285
+
286
+ /**
287
+ * After adding a new comment, it must be inserted in the correct
288
+ * location in the comment tree.
289
+ */
290
+ function insertComment(comment) {
291
+ var div = createCommentDiv(comment);
292
+
293
+ // To avoid stagnating data, don't store the comments children in data.
294
+ comment.children = null;
295
+ div.data('comment', comment);
296
+
297
+ var ul = $('#cl' + (comment.node || comment.parent));
298
+ var siblings = getChildren(ul);
299
+
300
+ var li = $(document.createElement('li'));
301
+ li.hide();
302
+
303
+ // Determine where in the parents children list to insert this comment.
304
+ for(i=0; i < siblings.length; i++) {
305
+ if (comp(comment, siblings[i]) <= 0) {
306
+ $('#cd' + siblings[i].id)
307
+ .parent()
308
+ .before(li.html(div));
309
+ li.slideDown('fast');
310
+ return;
311
+ }
312
+ }
313
+
314
+ // If we get here, this comment rates lower than all the others,
315
+ // or it is the only comment in the list.
316
+ ul.append(li.html(div));
317
+ li.slideDown('fast');
318
+ }
319
+
320
+ function acceptComment(id) {
321
+ $.ajax({
322
+ type: 'POST',
323
+ url: opts.acceptCommentURL,
324
+ data: {id: id},
325
+ success: function(data, textStatus, request) {
326
+ $('#cm' + id).fadeOut('fast');
327
+ $('#cd' + id).removeClass('moderate');
328
+ },
329
+ error: function(request, textStatus, error) {
330
+ showError('Oops, there was a problem accepting the comment.');
331
+ }
332
+ });
333
+ }
334
+
335
+ function deleteComment(id) {
336
+ $.ajax({
337
+ type: 'POST',
338
+ url: opts.deleteCommentURL,
339
+ data: {id: id},
340
+ success: function(data, textStatus, request) {
341
+ var div = $('#cd' + id);
342
+ if (data == 'delete') {
343
+ // Moderator mode: remove the comment and all children immediately
344
+ div.slideUp('fast', function() {
345
+ div.remove();
346
+ });
347
+ return;
348
+ }
349
+ // User mode: only mark the comment as deleted
350
+ div
351
+ .find('span.user-id:first')
352
+ .text('[deleted]').end()
353
+ .find('div.comment-text:first')
354
+ .text('[deleted]').end()
355
+ .find('#cm' + id + ', #dc' + id + ', #ac' + id + ', #rc' + id +
356
+ ', #sp' + id + ', #hp' + id + ', #cr' + id + ', #rl' + id)
357
+ .remove();
358
+ var comment = div.data('comment');
359
+ comment.username = '[deleted]';
360
+ comment.text = '[deleted]';
361
+ div.data('comment', comment);
362
+ },
363
+ error: function(request, textStatus, error) {
364
+ showError('Oops, there was a problem deleting the comment.');
365
+ }
366
+ });
367
+ }
368
+
369
+ function showProposal(id) {
370
+ $('#sp' + id).hide();
371
+ $('#hp' + id).show();
372
+ $('#pr' + id).slideDown('fast');
373
+ }
374
+
375
+ function hideProposal(id) {
376
+ $('#hp' + id).hide();
377
+ $('#sp' + id).show();
378
+ $('#pr' + id).slideUp('fast');
379
+ }
380
+
381
+ function showProposeChange(id) {
382
+ $('#pc' + id).hide();
383
+ $('#hc' + id).show();
384
+ var textarea = $('#pt' + id);
385
+ textarea.val(textarea.data('source'));
386
+ $.fn.autogrow.resize(textarea[0]);
387
+ textarea.slideDown('fast');
388
+ }
389
+
390
+ function hideProposeChange(id) {
391
+ $('#hc' + id).hide();
392
+ $('#pc' + id).show();
393
+ var textarea = $('#pt' + id);
394
+ textarea.val('').removeAttr('disabled');
395
+ textarea.slideUp('fast');
396
+ }
397
+
398
+ function toggleCommentMarkupBox(id) {
399
+ $('#mb' + id).toggle();
400
+ }
401
+
402
+ /** Handle when the user clicks on a sort by link. */
403
+ function handleReSort(link) {
404
+ var classes = link.attr('class').split(/\s+/);
405
+ for (var i=0; i<classes.length; i++) {
406
+ if (classes[i] != 'sort-option') {
407
+ by = classes[i].substring(2);
408
+ }
409
+ }
410
+ setComparator();
411
+ // Save/update the sortBy cookie.
412
+ var expiration = new Date();
413
+ expiration.setDate(expiration.getDate() + 365);
414
+ document.cookie= 'sortBy=' + escape(by) +
415
+ ';expires=' + expiration.toUTCString();
416
+ $('ul.comment-ul').each(function(index, ul) {
417
+ var comments = getChildren($(ul), true);
418
+ comments = sortComments(comments);
419
+ appendComments(comments, $(ul).empty());
420
+ });
421
+ }
422
+
423
+ /**
424
+ * Function to process a vote when a user clicks an arrow.
425
+ */
426
+ function handleVote(link) {
427
+ if (!opts.voting) {
428
+ showError("You'll need to login to vote.");
429
+ return;
430
+ }
431
+
432
+ var id = link.attr('id');
433
+ if (!id) {
434
+ // Didn't click on one of the voting arrows.
435
+ return;
436
+ }
437
+ // If it is an unvote, the new vote value is 0,
438
+ // Otherwise it's 1 for an upvote, or -1 for a downvote.
439
+ var value = 0;
440
+ if (id.charAt(1) != 'u') {
441
+ value = id.charAt(0) == 'u' ? 1 : -1;
442
+ }
443
+ // The data to be sent to the server.
444
+ var d = {
445
+ comment_id: id.substring(2),
446
+ value: value
447
+ };
448
+
449
+ // Swap the vote and unvote links.
450
+ link.hide();
451
+ $('#' + id.charAt(0) + (id.charAt(1) == 'u' ? 'v' : 'u') + d.comment_id)
452
+ .show();
453
+
454
+ // The div the comment is displayed in.
455
+ var div = $('div#cd' + d.comment_id);
456
+ var data = div.data('comment');
457
+
458
+ // If this is not an unvote, and the other vote arrow has
459
+ // already been pressed, unpress it.
460
+ if ((d.value !== 0) && (data.vote === d.value * -1)) {
461
+ $('#' + (d.value == 1 ? 'd' : 'u') + 'u' + d.comment_id).hide();
462
+ $('#' + (d.value == 1 ? 'd' : 'u') + 'v' + d.comment_id).show();
463
+ }
464
+
465
+ // Update the comments rating in the local data.
466
+ data.rating += (data.vote === 0) ? d.value : (d.value - data.vote);
467
+ data.vote = d.value;
468
+ div.data('comment', data);
469
+
470
+ // Change the rating text.
471
+ div.find('.rating:first')
472
+ .text(data.rating + ' point' + (data.rating == 1 ? '' : 's'));
473
+
474
+ // Send the vote information to the server.
475
+ $.ajax({
476
+ type: "POST",
477
+ url: opts.processVoteURL,
478
+ data: d,
479
+ error: function(request, textStatus, error) {
480
+ showError('Oops, there was a problem casting that vote.');
481
+ }
482
+ });
483
+ }
484
+
485
+ /**
486
+ * Open a reply form used to reply to an existing comment.
487
+ */
488
+ function openReply(id) {
489
+ // Swap out the reply link for the hide link
490
+ $('#rl' + id).hide();
491
+ $('#cr' + id).show();
492
+
493
+ // Add the reply li to the children ul.
494
+ var div = $(renderTemplate(replyTemplate, {id: id})).hide();
495
+ $('#cl' + id)
496
+ .prepend(div)
497
+ // Setup the submit handler for the reply form.
498
+ .find('#rf' + id)
499
+ .submit(function(event) {
500
+ event.preventDefault();
501
+ addComment($('#rf' + id));
502
+ closeReply(id);
503
+ })
504
+ .find('input[type=button]')
505
+ .click(function() {
506
+ closeReply(id);
507
+ });
508
+ div.slideDown('fast', function() {
509
+ $('#rf' + id).find('textarea').focus();
510
+ });
511
+ }
512
+
513
+ /**
514
+ * Close the reply form opened with openReply.
515
+ */
516
+ function closeReply(id) {
517
+ // Remove the reply div from the DOM.
518
+ $('#rd' + id).slideUp('fast', function() {
519
+ $(this).remove();
520
+ });
521
+
522
+ // Swap out the hide link for the reply link
523
+ $('#cr' + id).hide();
524
+ $('#rl' + id).show();
525
+ }
526
+
527
+ /**
528
+ * Recursively sort a tree of comments using the comp comparator.
529
+ */
530
+ function sortComments(comments) {
531
+ comments.sort(comp);
532
+ $.each(comments, function() {
533
+ this.children = sortComments(this.children);
534
+ });
535
+ return comments;
536
+ }
537
+
538
+ /**
539
+ * Get the children comments from a ul. If recursive is true,
540
+ * recursively include childrens' children.
541
+ */
542
+ function getChildren(ul, recursive) {
543
+ var children = [];
544
+ ul.children().children("[id^='cd']")
545
+ .each(function() {
546
+ var comment = $(this).data('comment');
547
+ if (recursive)
548
+ comment.children = getChildren($(this).find('#cl' + comment.id), true);
549
+ children.push(comment);
550
+ });
551
+ return children;
552
+ }
553
+
554
+ /** Create a div to display a comment in. */
555
+ function createCommentDiv(comment) {
556
+ if (!comment.displayed && !opts.moderator) {
557
+ return $('<div class="moderate">Thank you! Your comment will show up '
558
+ + 'once it is has been approved by a moderator.</div>');
559
+ }
560
+ // Prettify the comment rating.
561
+ comment.pretty_rating = comment.rating + ' point' +
562
+ (comment.rating == 1 ? '' : 's');
563
+ // Make a class (for displaying not yet moderated comments differently)
564
+ comment.css_class = comment.displayed ? '' : ' moderate';
565
+ // Create a div for this comment.
566
+ var context = $.extend({}, opts, comment);
567
+ var div = $(renderTemplate(commentTemplate, context));
568
+
569
+ // If the user has voted on this comment, highlight the correct arrow.
570
+ if (comment.vote) {
571
+ var direction = (comment.vote == 1) ? 'u' : 'd';
572
+ div.find('#' + direction + 'v' + comment.id).hide();
573
+ div.find('#' + direction + 'u' + comment.id).show();
574
+ }
575
+
576
+ if (opts.moderator || comment.text != '[deleted]') {
577
+ div.find('a.reply').show();
578
+ if (comment.proposal_diff)
579
+ div.find('#sp' + comment.id).show();
580
+ if (opts.moderator && !comment.displayed)
581
+ div.find('#cm' + comment.id).show();
582
+ if (opts.moderator || (opts.username == comment.username))
583
+ div.find('#dc' + comment.id).show();
584
+ }
585
+ return div;
586
+ }
587
+
588
+ /**
589
+ * A simple template renderer. Placeholders such as <%id%> are replaced
590
+ * by context['id'] with items being escaped. Placeholders such as <#id#>
591
+ * are not escaped.
592
+ */
593
+ function renderTemplate(template, context) {
594
+ var esc = $(document.createElement('div'));
595
+
596
+ function handle(ph, escape) {
597
+ var cur = context;
598
+ $.each(ph.split('.'), function() {
599
+ cur = cur[this];
600
+ });
601
+ return escape ? esc.text(cur || "").html() : cur;
602
+ }
603
+
604
+ return template.replace(/<([%#])([\w\.]*)\1>/g, function() {
605
+ return handle(arguments[2], arguments[1] == '%' ? true : false);
606
+ });
607
+ }
608
+
609
+ /** Flash an error message briefly. */
610
+ function showError(message) {
611
+ $(document.createElement('div')).attr({'class': 'popup-error'})
612
+ .append($(document.createElement('div'))
613
+ .attr({'class': 'error-message'}).text(message))
614
+ .appendTo('body')
615
+ .fadeIn("slow")
616
+ .delay(2000)
617
+ .fadeOut("slow");
618
+ }
619
+
620
+ /** Add a link the user uses to open the comments popup. */
621
+ $.fn.comment = function() {
622
+ return this.each(function() {
623
+ var id = $(this).attr('id').substring(1);
624
+ var count = COMMENT_METADATA[id];
625
+ var title = count + ' comment' + (count == 1 ? '' : 's');
626
+ var image = count > 0 ? opts.commentBrightImage : opts.commentImage;
627
+ var addcls = count == 0 ? ' nocomment' : '';
628
+ $(this)
629
+ .append(
630
+ $(document.createElement('a')).attr({
631
+ href: '#',
632
+ 'class': 'sphinx-comment-open' + addcls,
633
+ id: 'ao' + id
634
+ })
635
+ .append($(document.createElement('img')).attr({
636
+ src: image,
637
+ alt: 'comment',
638
+ title: title
639
+ }))
640
+ .click(function(event) {
641
+ event.preventDefault();
642
+ show($(this).attr('id').substring(2));
643
+ })
644
+ )
645
+ .append(
646
+ $(document.createElement('a')).attr({
647
+ href: '#',
648
+ 'class': 'sphinx-comment-close hidden',
649
+ id: 'ah' + id
650
+ })
651
+ .append($(document.createElement('img')).attr({
652
+ src: opts.closeCommentImage,
653
+ alt: 'close',
654
+ title: 'close'
655
+ }))
656
+ .click(function(event) {
657
+ event.preventDefault();
658
+ hide($(this).attr('id').substring(2));
659
+ })
660
+ );
661
+ });
662
+ };
663
+
664
+ var opts = {
665
+ processVoteURL: '/_process_vote',
666
+ addCommentURL: '/_add_comment',
667
+ getCommentsURL: '/_get_comments',
668
+ acceptCommentURL: '/_accept_comment',
669
+ deleteCommentURL: '/_delete_comment',
670
+ commentImage: '/static/_static/comment.png',
671
+ closeCommentImage: '/static/_static/comment-close.png',
672
+ loadingImage: '/static/_static/ajax-loader.gif',
673
+ commentBrightImage: '/static/_static/comment-bright.png',
674
+ upArrow: '/static/_static/up.png',
675
+ downArrow: '/static/_static/down.png',
676
+ upArrowPressed: '/static/_static/up-pressed.png',
677
+ downArrowPressed: '/static/_static/down-pressed.png',
678
+ voting: false,
679
+ moderator: false
680
+ };
681
+
682
+ if (typeof COMMENT_OPTIONS != "undefined") {
683
+ opts = jQuery.extend(opts, COMMENT_OPTIONS);
684
+ }
685
+
686
+ var popupTemplate = '\
687
+ <div class="sphinx-comments" id="sc<%id%>">\
688
+ <p class="sort-options">\
689
+ Sort by:\
690
+ <a href="#" class="sort-option byrating">best rated</a>\
691
+ <a href="#" class="sort-option byascage">newest</a>\
692
+ <a href="#" class="sort-option byage">oldest</a>\
693
+ </p>\
694
+ <div class="comment-header">Comments</div>\
695
+ <div class="comment-loading" id="cn<%id%>">\
696
+ loading comments... <img src="<%loadingImage%>" alt="" /></div>\
697
+ <ul id="cl<%id%>" class="comment-ul"></ul>\
698
+ <div id="ca<%id%>">\
699
+ <p class="add-a-comment">Add a comment\
700
+ (<a href="#" class="comment-markup" id="ab<%id%>">markup</a>):</p>\
701
+ <div class="comment-markup-box" id="mb<%id%>">\
702
+ reStructured text markup: <i>*emph*</i>, <b>**strong**</b>, \
703
+ <code>``code``</code>, \
704
+ code blocks: <code>::</code> and an indented block after blank line</div>\
705
+ <form method="post" id="cf<%id%>" class="comment-form" action="">\
706
+ <textarea name="comment" cols="80"></textarea>\
707
+ <p class="propose-button">\
708
+ <a href="#" id="pc<%id%>" class="show-propose-change">\
709
+ Propose a change &#9657;\
710
+ </a>\
711
+ <a href="#" id="hc<%id%>" class="hide-propose-change">\
712
+ Propose a change &#9663;\
713
+ </a>\
714
+ </p>\
715
+ <textarea name="proposal" id="pt<%id%>" cols="80"\
716
+ spellcheck="false"></textarea>\
717
+ <input type="submit" value="Add comment" />\
718
+ <input type="hidden" name="node" value="<%id%>" />\
719
+ <input type="hidden" name="parent" value="" />\
720
+ </form>\
721
+ </div>\
722
+ </div>';
723
+
724
+ var commentTemplate = '\
725
+ <div id="cd<%id%>" class="sphinx-comment<%css_class%>">\
726
+ <div class="vote">\
727
+ <div class="arrow">\
728
+ <a href="#" id="uv<%id%>" class="vote" title="vote up">\
729
+ <img src="<%upArrow%>" />\
730
+ </a>\
731
+ <a href="#" id="uu<%id%>" class="un vote" title="vote up">\
732
+ <img src="<%upArrowPressed%>" />\
733
+ </a>\
734
+ </div>\
735
+ <div class="arrow">\
736
+ <a href="#" id="dv<%id%>" class="vote" title="vote down">\
737
+ <img src="<%downArrow%>" id="da<%id%>" />\
738
+ </a>\
739
+ <a href="#" id="du<%id%>" class="un vote" title="vote down">\
740
+ <img src="<%downArrowPressed%>" />\
741
+ </a>\
742
+ </div>\
743
+ </div>\
744
+ <div class="comment-content">\
745
+ <p class="tagline comment">\
746
+ <span class="user-id"><%username%></span>\
747
+ <span class="rating"><%pretty_rating%></span>\
748
+ <span class="delta"><%time.delta%></span>\
749
+ </p>\
750
+ <div class="comment-text comment"><#text#></div>\
751
+ <p class="comment-opts comment">\
752
+ <a href="#" class="reply hidden" id="rl<%id%>">reply &#9657;</a>\
753
+ <a href="#" class="close-reply" id="cr<%id%>">reply &#9663;</a>\
754
+ <a href="#" id="sp<%id%>" class="show-proposal">proposal &#9657;</a>\
755
+ <a href="#" id="hp<%id%>" class="hide-proposal">proposal &#9663;</a>\
756
+ <a href="#" id="dc<%id%>" class="delete-comment hidden">delete</a>\
757
+ <span id="cm<%id%>" class="moderation hidden">\
758
+ <a href="#" id="ac<%id%>" class="accept-comment">accept</a>\
759
+ </span>\
760
+ </p>\
761
+ <pre class="proposal" id="pr<%id%>">\
762
+ <#proposal_diff#>\
763
+ </pre>\
764
+ <ul class="comment-children" id="cl<%id%>"></ul>\
765
+ </div>\
766
+ <div class="clearleft"></div>\
767
+ </div>\
768
+ </div>';
769
+
770
+ var replyTemplate = '\
771
+ <li>\
772
+ <div class="reply-div" id="rd<%id%>">\
773
+ <form id="rf<%id%>">\
774
+ <textarea name="comment" cols="80"></textarea>\
775
+ <input type="submit" value="Add reply" />\
776
+ <input type="button" value="Cancel" />\
777
+ <input type="hidden" name="parent" value="<%id%>" />\
778
+ <input type="hidden" name="node" value="" />\
779
+ </form>\
780
+ </div>\
781
+ </li>';
782
+
783
+ $(document).ready(function() {
784
+ init();
785
+ });
786
+ })(jQuery);
787
+
788
+ $(document).ready(function() {
789
+ // add comment anchors for all paragraphs that are commentable
790
+ $('.sphinx-has-comment').comment();
791
+
792
+ // highlight search words in search results
793
+ $("div.context").each(function() {
794
+ var params = $.getQueryParameters();
795
+ var terms = (params.q) ? params.q[0].split(/\s+/) : [];
796
+ var result = $(this);
797
+ $.each(terms, function() {
798
+ result.highlightText(this.toLowerCase(), 'highlighted');
799
+ });
800
+ });
801
+
802
+ // directly open comment window if requested
803
+ var anchor = document.location.hash;
804
+ if (anchor.substring(0, 9) == '#comment-') {
805
+ $('#ao' + anchor.substring(9)).click();
806
+ document.location.hash = '#s' + anchor.substring(9);
807
+ }
808
+ });