Skip to content
Browse files

Merged branch MOAB into master

  • Loading branch information...
1 parent 8d8a8d5 commit 4f7289d1e4b6be440f3b45085c4414b8c15abd91 @glesperance committed Aug 30, 2011
Showing with 11,747 additions and 1,823 deletions.
  1. +1 −0 lib/client/index.js
  2. +4 −0 lib/client/rocket-js/vendors/Modernizr-2.0.6.min.js
  3. +1 −0 lib/client/rocket-js/vendors/jade-runtime-0.15.2.min.js
  4. +32 −0 lib/client/rocket-js/vendors/require-0.24.0.min.js
  5. +62 −0 lib/config.js
  6. +442 −0 lib/controller.js
  7. +139 −0 lib/export.js
  8. 0 {libs/generators → lib/generator}/_project_generator/_project_generator.js
  9. 0 {libs/generators → lib/generator}/_project_generator/index.js
  10. 0 ...nerators → lib/generator}/_project_generator/templates/default/client/static/apple-touch-icon.png
  11. 0 ...s/generators → lib/generator}/_project_generator/templates/default/client/static/css/handheld.css
  12. 0 {libs/generators → lib/generator}/_project_generator/templates/default/client/static/css/style.css
  13. 0 {libs/generators → lib/generator}/_project_generator/templates/default/client/static/favicon.ico
  14. 0 {libs → lib/generator/_project_generator/templates/default/client/static/img}/logo.png
  15. 0 ...s/generators → lib/generator}/_project_generator/templates/default/controllers/root_controller.js
  16. 0 ...tor/templates/default/plugins → lib/generator/_project_generator/templates/default/exports}/empty
  17. 0 {libs/generators → lib/generator}/_project_generator/templates/default/launcher.js
  18. 0 {libs/generators → lib/generator}/_project_generator/templates/default/models/empty
  19. +1 −1 {libs/generators → lib/generator}/_project_generator/templates/default/views/layout.jade
  20. +1 −0 lib/generator/_project_generator/templates/default/views/root/root.index.jade
  21. 0 {libs/generators → lib/generator}/controller_generator/controller_generator.js
  22. 0 {libs/generators → lib/generator}/controller_generator/index.js
  23. +18 −0 lib/index.js
  24. +103 −0 lib/loader.js
  25. +114 −0 lib/locale.js
  26. 0 {libs/generators/_project_generator/templates/default/client/static/img → lib}/logo.png
  27. +486 −0 lib/util/async_fs.js
  28. +95 −0 lib/util/dadt.js
  29. +90 −0 lib/util/file_event_emitter.js
  30. +7 −0 lib/util/index.js
  31. 0 {libs/utils → lib/util}/namespace.js
  32. +128 −0 lib/util/tmpdir.js
  33. +8,273 −0 lib/vendors/r.js
  34. +140 −0 lib/view.js
  35. +0 −6 libs/generators/_project_generator/templates/default/client/js/root_client.js
  36. +0 −13 libs/generators/_project_generator/templates/default/client/js/vendors/dd_belatedpng.js
  37. +0 −18 libs/generators/_project_generator/templates/default/client/js/vendors/jquery-1.6.1.min.js
  38. +0 −2 libs/generators/_project_generator/templates/default/client/static/modernizr-1.7.min.js
  39. +0 −10 libs/generators/_project_generator/templates/default/views/root/root.index.jade
  40. +0 −152 libs/resources/base_resource.js
  41. +0 −630 libs/resources/couchdb_resource.js
  42. +0 −4 libs/resources/index.js
  43. +0 −130 libs/utils/oo.js
  44. +0 −28 libs/views/filters.js
  45. +0 −239 libs/views/helpers.js
  46. +8 −7 package.json
  47. +1 −0 rocket.js
  48. +0 −583 rocket_main.js
  49. +358 −0 spec/client_loader_spec.js
  50. +203 −0 spec/controller_loader_spec.js
  51. +265 −0 spec/exports_loader_spec.js
  52. +8 −0 spec/lib/test_config.js
  53. +439 −0 spec/lib/test_project/client/css/lib/normalize.css
  54. +63 −0 spec/lib/test_project/client/css/style.css
  55. +3 −0 spec/lib/test_project/client/js/lib/jquery.alpha.js
  56. +3 −0 spec/lib/test_project/client/js/lib/jquery.beta.js
  57. +5 −0 spec/lib/test_project/client/js/require.config.json
  58. +6 −0 spec/lib/test_project/client/js/root_client.js
  59. +2 −0 spec/lib/test_project/client/js/views/test.jade
  60. BIN spec/lib/test_project/client/static/favicon.ico
  61. +20 −0 spec/lib/test_project/controllers/dummies_controller.js
  62. +1 −0 spec/lib/test_project/controllers/shapeshifters_controller.js
  63. +7 −0 spec/lib/test_project/exports/func.js
  64. +7 −0 spec/lib/test_project/exports/obj.js
  65. +1 −0 spec/lib/test_project/exports/shapeshifter.js
  66. 0 ...mplates/default/models/datasources/empty → spec/lib/test_project/views/dummies/dummies.index.jade
  67. 0 ...generator/templates/default/exports/empty → spec/lib/test_project/views/dummies/dummies.show.jade
  68. +42 −0 spec/lib/test_project/views/layout.jade
  69. +168 −0 spec/view_loader_spec.js
View
1 lib/client/index.js
@@ -0,0 +1 @@
+module.exports = require('./client');
View
4 lib/client/rocket-js/vendors/Modernizr-2.0.6.min.js
@@ -0,0 +1,4 @@
+/* Modernizr 2.0.6 (Custom Build) | MIT & BSD
+ * Contains: fontface | backgroundsize | borderimage | borderradius | boxshadow | flexbox | hsla | multiplebgs | opacity | rgba | textshadow | cssanimations | csscolumns | generatedcontent | cssgradients | cssreflections | csstransforms | csstransforms3d | csstransitions | applicationcache | canvas | canvastext | draganddrop | hashchange | history | audio | video | indexeddb | input | inputtypes | localstorage | postmessage | sessionstorage | websockets | websqldatabase | webworkers | geolocation | inlinesvg | smil | svg | svgclippaths | touch | webgl | iepp | respond | mq | cssclasses | addtest | prefixed | teststyles | testprop | testallprops | hasevent | prefixes | domprefixes | load
+ */
+;window.Modernizr=function(a,b,c){function I(){e.input=function(a){for(var b=0,c=a.length;b<c;b++)t[a[b]]=a[b]in l;return t}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")),e.inputtypes=function(a){for(var d=0,e,f,h,i=a.length;d<i;d++)l.setAttribute("type",f=a[d]),e=l.type!=="text",e&&(l.value=m,l.style.cssText="position:absolute;visibility:hidden;",/^range$/.test(f)&&l.style.WebkitAppearance!==c?(g.appendChild(l),h=b.defaultView,e=h.getComputedStyle&&h.getComputedStyle(l,null).WebkitAppearance!=="textfield"&&l.offsetHeight!==0,g.removeChild(l)):/^(search|tel)$/.test(f)||(/^(url|email)$/.test(f)?e=l.checkValidity&&l.checkValidity()===!1:/^color$/.test(f)?(g.appendChild(l),g.offsetWidth,e=l.value!=m,g.removeChild(l)):e=l.value!=m)),s[a[d]]=!!e;return s}("search tel url email datetime date month week time datetime-local number range color".split(" "))}function G(a,b){var c=a.charAt(0).toUpperCase()+a.substr(1),d=(a+" "+p.join(c+" ")+c).split(" ");return F(d,b)}function F(a,b){for(var d in a)if(k[a[d]]!==c)return b=="pfx"?a[d]:!0;return!1}function E(a,b){return!!~(""+a).indexOf(b)}function D(a,b){return typeof a===b}function C(a,b){return B(o.join(a+";")+(b||""))}function B(a){k.cssText=a}var d="2.0.6",e={},f=!0,g=b.documentElement,h=b.head||b.getElementsByTagName("head")[0],i="modernizr",j=b.createElement(i),k=j.style,l=b.createElement("input"),m=":)",n=Object.prototype.toString,o=" -webkit- -moz- -o- -ms- -khtml- ".split(" "),p="Webkit Moz O ms Khtml".split(" "),q={svg:"http://www.w3.org/2000/svg"},r={},s={},t={},u=[],v=function(a,c,d,e){var f,h,j,k=b.createElement("div");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:i+(d+1),k.appendChild(j);f=["&shy;","<style>",a,"</style>"].join(""),k.id=i,k.innerHTML+=f,g.appendChild(k),h=c(k,a),k.parentNode.removeChild(k);return!!h},w=function(b){if(a.matchMedia)return matchMedia(b).matches;var c;v("@media "+b+" { #"+i+" { position: absolute; } }",function(b){c=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle).position=="absolute"});return c},x=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=D(e[d],"function"),D(e[d],c)||(e[d]=c),e.removeAttribute(d))),e=null;return f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),y,z={}.hasOwnProperty,A;!D(z,c)&&!D(z.call,c)?A=function(a,b){return z.call(a,b)}:A=function(a,b){return b in a&&D(a.constructor.prototype[b],c)};var H=function(c,d){var f=c.join(""),g=d.length;v(f,function(c,d){var f=b.styleSheets[b.styleSheets.length-1],h=f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"",i=c.childNodes,j={};while(g--)j[i[g].id]=i[g];e.touch="ontouchstart"in a||j.touch.offsetTop===9,e.csstransforms3d=j.csstransforms3d.offsetLeft===9,e.generatedcontent=j.generatedcontent.offsetHeight>=1,e.fontface=/src/i.test(h)&&h.indexOf(d.split(" ")[0])===0},g,d)}(['@font-face {font-family:"font";src:url("https://")}',["@media (",o.join("touch-enabled),("),i,")","{#touch{top:9px;position:absolute}}"].join(""),["@media (",o.join("transform-3d),("),i,")","{#csstransforms3d{left:9px;position:absolute}}"].join(""),['#generatedcontent:after{content:"',m,'";visibility:hidden}'].join("")],["fontface","touch","csstransforms3d","generatedcontent"]);r.flexbox=function(){function c(a,b,c,d){a.style.cssText=o.join(b+":"+c+";")+(d||"")}function a(a,b,c,d){b+=":",a.style.cssText=(b+o.join(c+";"+b)).slice(0,-b.length)+(d||"")}var d=b.createElement("div"),e=b.createElement("div");a(d,"display","box","width:42px;padding:0;"),c(e,"box-flex","1","width:10px;"),d.appendChild(e),g.appendChild(d);var f=e.offsetWidth===42;d.removeChild(e),g.removeChild(d);return f},r.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},r.canvastext=function(){return!!e.canvas&&!!D(b.createElement("canvas").getContext("2d").fillText,"function")},r.webgl=function(){return!!a.WebGLRenderingContext},r.touch=function(){return e.touch},r.geolocation=function(){return!!navigator.geolocation},r.postmessage=function(){return!!a.postMessage},r.websqldatabase=function(){var b=!!a.openDatabase;return b},r.indexedDB=function(){for(var b=-1,c=p.length;++b<c;)if(a[p[b].toLowerCase()+"IndexedDB"])return!0;return!!a.indexedDB},r.hashchange=function(){return x("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},r.history=function(){return!!a.history&&!!history.pushState},r.draganddrop=function(){return x("dragstart")&&x("drop")},r.websockets=function(){for(var b=-1,c=p.length;++b<c;)if(a[p[b]+"WebSocket"])return!0;return"WebSocket"in a},r.rgba=function(){B("background-color:rgba(150,255,150,.5)");return E(k.backgroundColor,"rgba")},r.hsla=function(){B("background-color:hsla(120,40%,100%,.5)");return E(k.backgroundColor,"rgba")||E(k.backgroundColor,"hsla")},r.multiplebgs=function(){B("background:url(https://),url(https://),red url(https://)");return/(url\s*\(.*?){3}/.test(k.background)},r.backgroundsize=function(){return G("backgroundSize")},r.borderimage=function(){return G("borderImage")},r.borderradius=function(){return G("borderRadius")},r.boxshadow=function(){return G("boxShadow")},r.textshadow=function(){return b.createElement("div").style.textShadow===""},r.opacity=function(){C("opacity:.55");return/^0.55$/.test(k.opacity)},r.cssanimations=function(){return G("animationName")},r.csscolumns=function(){return G("columnCount")},r.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";B((a+o.join(b+a)+o.join(c+a)).slice(0,-a.length));return E(k.backgroundImage,"gradient")},r.cssreflections=function(){return G("boxReflect")},r.csstransforms=function(){return!!F(["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"])},r.csstransforms3d=function(){var a=!!F(["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"]);a&&"webkitPerspective"in g.style&&(a=e.csstransforms3d);return a},r.csstransitions=function(){return G("transitionProperty")},r.fontface=function(){return e.fontface},r.generatedcontent=function(){return e.generatedcontent},r.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType){c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"');var d='video/mp4; codecs="avc1.42E01E';c.h264=a.canPlayType(d+'"')||a.canPlayType(d+', mp4a.40.2"'),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"')}}catch(e){}return c},r.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"'),c.mp3=a.canPlayType("audio/mpeg;"),c.wav=a.canPlayType('audio/wav; codecs="1"'),c.m4a=a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")}catch(d){}return c},r.localstorage=function(){try{return!!localStorage.getItem}catch(a){return!1}},r.sessionstorage=function(){try{return!!sessionStorage.getItem}catch(a){return!1}},r.webworkers=function(){return!!a.Worker},r.applicationcache=function(){return!!a.applicationCache},r.svg=function(){return!!b.createElementNS&&!!b.createElementNS(q.svg,"svg").createSVGRect},r.inlinesvg=function(){var a=b.createElement("div");a.innerHTML="<svg/>";return(a.firstChild&&a.firstChild.namespaceURI)==q.svg},r.smil=function(){return!!b.createElementNS&&/SVG/.test(n.call(b.createElementNS(q.svg,"animate")))},r.svgclippaths=function(){return!!b.createElementNS&&/SVG/.test(n.call(b.createElementNS(q.svg,"clipPath")))};for(var J in r)A(r,J)&&(y=J.toLowerCase(),e[y]=r[J](),u.push((e[y]?"":"no-")+y));e.input||I(),e.addTest=function(a,b){if(typeof a=="object")for(var d in a)A(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return;b=typeof b=="boolean"?b:!!b(),g.className+=" "+(b?"":"no-")+a,e[a]=b}return e},B(""),j=l=null,a.attachEvent&&function(){var a=b.createElement("div");a.innerHTML="<elem></elem>";return a.childNodes.length!==1}()&&function(a,b){function s(a){var b=-1;while(++b<g)a.createElement(f[b])}a.iepp=a.iepp||{};var d=a.iepp,e=d.html5elements||"abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",f=e.split("|"),g=f.length,h=new RegExp("(^|\\s)("+e+")","gi"),i=new RegExp("<(/*)("+e+")","gi"),j=/^\s*[\{\}]\s*$/,k=new RegExp("(^|[^\\n]*?\\s)("+e+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),l=b.createDocumentFragment(),m=b.documentElement,n=m.firstChild,o=b.createElement("body"),p=b.createElement("style"),q=/print|all/,r;d.getCSS=function(a,b){if(a+""===c)return"";var e=-1,f=a.length,g,h=[];while(++e<f){g=a[e];if(g.disabled)continue;b=g.media||b,q.test(b)&&h.push(d.getCSS(g.imports,b),g.cssText),b="all"}return h.join("")},d.parseCSS=function(a){var b=[],c;while((c=k.exec(a))!=null)b.push(((j.exec(c[1])?"\n":c[1])+c[2]+c[3]).replace(h,"$1.iepp_$2")+c[4]);return b.join("\n")},d.writeHTML=function(){var a=-1;r=r||b.body;while(++a<g){var c=b.getElementsByTagName(f[a]),d=c.length,e=-1;while(++e<d)c[e].className.indexOf("iepp_")<0&&(c[e].className+=" iepp_"+f[a])}l.appendChild(r),m.appendChild(o),o.className=r.className,o.id=r.id,o.innerHTML=r.innerHTML.replace(i,"<$1font")},d._beforePrint=function(){p.styleSheet.cssText=d.parseCSS(d.getCSS(b.styleSheets,"all")),d.writeHTML()},d.restoreHTML=function(){o.innerHTML="",m.removeChild(o),m.appendChild(r)},d._afterPrint=function(){d.restoreHTML(),p.styleSheet.cssText=""},s(b),s(l);d.disablePP||(n.insertBefore(p,n.firstChild),p.media="print",p.className="iepp-printshim",a.attachEvent("onbeforeprint",d._beforePrint),a.attachEvent("onafterprint",d._afterPrint))}(a,b),e._version=d,e._prefixes=o,e._domPrefixes=p,e.mq=w,e.hasEvent=x,e.testProp=function(a){return F([a])},e.testAllProps=G,e.testStyles=v,e.prefixed=function(a){return G(a,"pfx")},g.className=g.className.replace(/\bno-js\b/,"")+(f?" js "+u.join(" "):"");return e}(this,this.document),function(a,b){function u(){r(!0)}a.respond={},respond.update=function(){},respond.mediaQueriesSupported=b;if(!b){var c=a.document,d=c.documentElement,e=[],f=[],g=[],h={},i=30,j=c.getElementsByTagName("head")[0]||d,k=j.getElementsByTagName("link"),l=[],m=function(){var b=k,c=b.length,d=0,e,f,g,i;for(;d<c;d++)e=b[d],f=e.href,g=e.media,i=e.rel&&e.rel.toLowerCase()==="stylesheet",!!f&&i&&!h[f]&&(!/^([a-zA-Z]+?:(\/\/)?(www\.)?)/.test(f)||f.replace(RegExp.$1,"").split("/")[0]===a.location.host?l.push({href:f,media:g}):h[f]=!0);n()},n=function(){if(l.length){var a=l.shift();s(a.href,function(b){o(b,a.href,a.media),h[a.href]=!0,n()})}},o=function(a,b,c){var d=a.match(/@media[^\{]+\{([^\{\}]+\{[^\}\{]+\})+/gi),g=d&&d.length||0,b=b.substring(0,b.lastIndexOf("/")),h=function(a){return a.replace(/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,"$1"+b+"$2$3")},i=!g&&c,j=0,k,l,m,n,o;b.length&&(b+="/"),i&&(g=1);for(;j<g;j++){k=0,i?(l=c,f.push(h(a))):(l=d[j].match(/@media ([^\{]+)\{([\S\s]+?)$/)&&RegExp.$1,f.push(RegExp.$2&&h(RegExp.$2))),n=l.split(","),o=n.length;for(;k<o;k++)m=n[k],e.push({media:m.match(/(only\s+)?([a-zA-Z]+)(\sand)?/)&&RegExp.$2,rules:f.length-1,minw:m.match(/\(min\-width:[\s]*([\s]*[0-9]+)px[\s]*\)/)&&parseFloat(RegExp.$1),maxw:m.match(/\(max\-width:[\s]*([\s]*[0-9]+)px[\s]*\)/)&&parseFloat(RegExp.$1)})}r()},p,q,r=function(a){var b="clientWidth",h=d[b],l=c.compatMode==="CSS1Compat"&&h||c.body[b]||h,m={},n=c.createDocumentFragment(),o=k[k.length-1],s=(new Date).getTime();if(a&&p&&s-p<i)clearTimeout(q),q=setTimeout(r,i);else{p=s;for(var t in e){var u=e[t];if(!u.minw&&!u.maxw||(!u.minw||u.minw&&l>=u.minw)&&(!u.maxw||u.maxw&&l<=u.maxw))m[u.media]||(m[u.media]=[]),m[u.media].push(f[u.rules])}for(var t in g)g[t]&&g[t].parentNode===j&&j.removeChild(g[t]);for(var t in m){var v=c.createElement("style"),w=m[t].join("\n");v.type="text/css",v.media=t,v.styleSheet?v.styleSheet.cssText=w:v.appendChild(c.createTextNode(w)),n.appendChild(v),g.push(v)}j.insertBefore(n,o.nextSibling)}},s=function(a,b){var c=t();if(!!c){c.open("GET",a,!0),c.onreadystatechange=function(){c.readyState==4&&(c.status==200||c.status==304)&&b(c.responseText)};if(c.readyState==4)return;c.send()}},t=function(){var a=!1,b=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new XMLHttpRequest}],c=b.length;while(c--){try{a=b[c]()}catch(d){continue}break}return function(){return a}}();m(),respond.update=m,a.addEventListener?a.addEventListener("resize",u,!1):a.attachEvent&&a.attachEvent("onresize",u)}}(this,Modernizr.mq("only all")),function(a,b,c){function k(a){return!a||a=="loaded"||a=="complete"}function j(){var a=1,b=-1;while(p.length- ++b)if(p[b].s&&!(a=p[b].r))break;a&&g()}function i(a){var c=b.createElement("script"),d;c.src=a.s,c.onreadystatechange=c.onload=function(){!d&&k(c.readyState)&&(d=1,j(),c.onload=c.onreadystatechange=null)},m(function(){d||(d=1,j())},H.errorTimeout),a.e?c.onload():n.parentNode.insertBefore(c,n)}function h(a){var c=b.createElement("link"),d;c.href=a.s,c.rel="stylesheet",c.type="text/css";if(!a.e&&(w||r)){var e=function(a){m(function(){if(!d)try{a.sheet.cssRules.length?(d=1,j()):e(a)}catch(b){b.code==1e3||b.message=="security"||b.message=="denied"?(d=1,m(function(){j()},0)):e(a)}},0)};e(c)}else c.onload=function(){d||(d=1,m(function(){j()},0))},a.e&&c.onload();m(function(){d||(d=1,j())},H.errorTimeout),!a.e&&n.parentNode.insertBefore(c,n)}function g(){var a=p.shift();q=1,a?a.t?m(function(){a.t=="c"?h(a):i(a)},0):(a(),j()):q=0}function f(a,c,d,e,f,h){function i(){!o&&k(l.readyState)&&(r.r=o=1,!q&&j(),l.onload=l.onreadystatechange=null,m(function(){u.removeChild(l)},0))}var l=b.createElement(a),o=0,r={t:d,s:c,e:h};l.src=l.data=c,!s&&(l.style.display="none"),l.width=l.height="0",a!="object"&&(l.type=d),l.onload=l.onreadystatechange=i,a=="img"?l.onerror=i:a=="script"&&(l.onerror=function(){r.e=r.r=1,g()}),p.splice(e,0,r),u.insertBefore(l,s?null:n),m(function(){o||(u.removeChild(l),r.r=r.e=o=1,j())},H.errorTimeout)}function e(a,b,c){var d=b=="c"?z:y;q=0,b=b||"j",C(a)?f(d,a,b,this.i++,l,c):(p.splice(this.i++,0,a),p.length==1&&g());return this}function d(){var a=H;a.loader={load:e,i:0};return a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=r&&!s,u=s?l:n.parentNode,v=a.opera&&o.call(a.opera)=="[object Opera]",w="webkitAppearance"in l.style,x=w&&"async"in b.createElement("script"),y=r?"object":v||x?"img":"script",z=w?"img":y,A=Array.isArray||function(a){return o.call(a)=="[object Array]"},B=function(a){return Object(a)===a},C=function(a){return typeof a=="string"},D=function(a){return o.call(a)=="[object Function]"},E=[],F={},G,H;H=function(a){function f(a){var b=a.split("!"),c=E.length,d=b.pop(),e=b.length,f={url:d,origUrl:d,prefixes:b},g,h;for(h=0;h<e;h++)g=F[b[h]],g&&(f=g(f));for(h=0;h<c;h++)f=E[h](f);return f}function e(a,b,e,g,h){var i=f(a),j=i.autoCallback;if(!i.bypass){b&&(b=D(b)?b:b[a]||b[g]||b[a.split("/").pop().split("?")[0]]);if(i.instead)return i.instead(a,b,e,g,h);e.load(i.url,i.forceCSS||!i.forceJS&&/css$/.test(i.url)?"c":c,i.noexec),(D(b)||D(j))&&e.load(function(){d(),b&&b(i.origUrl,h,g),j&&j(i.origUrl,h,g)})}}function b(a,b){function c(a){if(C(a))e(a,h,b,0,d);else if(B(a))for(i in a)a.hasOwnProperty(i)&&e(a[i],h,b,i,d)}var d=!!a.test,f=d?a.yep:a.nope,g=a.load||a.both,h=a.callback,i;c(f),c(g),a.complete&&b.load(a.complete)}var g,h,i=this.yepnope.loader;if(C(a))e(a,0,i,0);else if(A(a))for(g=0;g<a.length;g++)h=a[g],C(h)?e(h,0,i,0):A(h)?H(h):B(h)&&b(h,i);else B(a)&&b(a,i)},H.addPrefix=function(a,b){F[a]=b},H.addFilter=function(a){E.push(a)},H.errorTimeout=1e4,b.readyState==null&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",G=function(){b.removeEventListener("DOMContentLoaded",G,0),b.readyState="complete"},0)),a.yepnope=d()}(this,this.document),Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0))};
View
1 lib/client/rocket-js/vendors/jade-runtime-0.15.2.min.js
@@ -0,0 +1 @@
+var jade=function(exports){Array.isArray||(Array.isArray=function(arr){return"[object Array]"==toString.call(arr)}),Object.keys||(Object.keys=function(obj){var arr=[];for(var key in obj)obj.hasOwnProperty(key)&&arr.push(obj);return arr}),exports.attrs=function(obj){var buf=[],terse=obj.terse;delete obj.terse;var keys=Object.keys(obj),len=keys.length;if(len){buf.push("");for(var i=0;i<len;++i){var key=keys[i],val=obj[key];"boolean"==typeof val||null==val?val&&(terse?buf.push(key):buf.push(key+'="'+key+'"')):"class"==key&&Array.isArray(val)?buf.push(key+'="'+exports.escape(val.join(" "))+'"'):buf.push(key+'="'+exports.escape(val)+'"')}}return buf.join(" ")},exports.escape=function(html){return String(html).replace(/&(?!\w+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},exports.rethrow=function(err,str,filename,lineno){var context=3,lines=str.split("\n"),start=Math.max(lineno-context,0),end=Math.min(lines.length,lineno+context),context=lines.slice(start,end).map(function(line,i){var curr=i+start+1;return(curr==lineno?" > ":" ")+curr+"| "+line}).join("\n");err.path=filename,err.message=(filename||"Jade")+":"+lineno+"\n"+context+"\n\n"+err.message;throw err};return exports}({})
View
32 lib/client/rocket-js/vendors/require-0.24.0.min.js
@@ -0,0 +1,32 @@
+/*
+ RequireJS 0.24.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
+ Available via the MIT or new BSD license.
+ see: http://github.com/jrburke/requirejs for details
+*/
+var require,define;
+(function(){function Q(e){return da.call(e)==="[object Function]"}function V(e){return da.call(e)==="[object Array]"}function W(e,g,l){for(var k in g)if(!(k in F)&&(!(k in e)||l))e[k]=g[k];return h}function ea(e,g,l){var k,p,n;for(k=0;n=g[k];k++){n=typeof n==="string"?{name:n}:n;p=n.location;if(l&&(!p||p.indexOf("/")!==0&&p.indexOf(":")===-1))p=l+"/"+(p||n.name);e[n.name]={name:n.name,location:p||n.name,lib:n.lib||"lib",main:(n.main||"lib/main").replace(qa,"").replace(fa,"")}}}function ra(e){function g(a){var b,
+c;for(b=0;c=a[b];b++)if(c==="."){a.splice(b,1);b-=1}else if(c==="..")if(b===1&&(a[2]===".."||a[0]===".."))break;else if(b>0){a.splice(b-1,2);b-=2}}function l(a,b){var c;if(a.charAt(0)===".")if(b){if(t.pkgs[b])b=[b];else{b=b.split("/");b=b.slice(0,b.length-1)}a=b.concat(a.split("/"));g(a);c=t.pkgs[b=a[0]];a=a.join("/");if(c&&a===b+"/"+c.main)a=b}return a}function k(a,b){var c=a?a.indexOf("!"):-1,d=null,f=b?b.name:null,j=a,o,m;if(c!==-1){d=a.substring(0,c);a=a.substring(c+1,a.length)}if(d)d=l(d,f);
+if(a){if(d)o=(c=q[d])?c.normalize?c.normalize(a,function(u){return l(u,f)}):l(a,f):"__$p"+f+"@"+a;else o=l(a,f);m=X[o];if(!m){m=h.toModuleUrl?h.toModuleUrl(i,a,b):i.nameToUrl(a,null,b);X[o]=m}}return{prefix:d,name:o,parentMap:b,url:m,originalName:j,fullName:d?d+"!"+o:o}}function p(){var a=true,b=t.priorityWait,c,d;if(b){for(d=0;c=b[d];d++)if(!v[c]){a=false;break}a&&delete t.priorityWait}return a}function n(a){return function(b){a.exports=b}}function R(a,b,c){return function(){var d=[].concat(sa.call(arguments,
+0)),f;if(c&&Q(f=d[d.length-1]))f.__requireJsBuild=true;d.push(b);return a.apply(null,d)}}function ga(a,b){b=R(i.require,a,b);W(b,{nameToUrl:R(i.nameToUrl,a),toUrl:R(i.toUrl,a),isDefined:R(i.isDefined,a),ready:h.ready,isBrowser:h.isBrowser});if(h.paths)b.paths=h.paths;return b}function ta(a){var b,c,d,f,j,o,m,u=S[a];if(u)for(f=0;c=u[f];f++){b=c.fullName;c=k(c.originalName,c.parentMap);c=c.fullName;d=w[b]||[];j=w[c];if(c!==b){if(b in z){delete z[b];z[c]=true}w[c]=j?j.concat(d):d;delete w[b];for(j=0;j<
+d.length;j++){m=d[j].depArray;for(o=0;o<m.length;o++)if(m[o]===b)m[o]=c}}}delete S[a]}function ha(a){var b=a.prefix,c=a.fullName;if(!(z[c]||c in q)){if(b&&!G[b]){G[b]=undefined;(S[b]||(S[b]=[])).push(a);(w[b]||(w[b]=[])).push({onDep:function(d){d===b&&ta(b)}});ha(k(b))}i.paused.push(a)}}function Y(a){var b,c,d;b=a.callback;var f=a.fullName;d=[];var j=a.depArray;if(b&&Q(b)){if(j)for(b=0;b<j.length;b++)d.push(a.deps[j[b]]);c=h.execCb(f,a.callback,d);if(f)if(a.usingExports&&c===undefined&&(!a.cjsModule||
+!("exports"in a.cjsModule)))c=q[f];else if(a.cjsModule&&"exports"in a.cjsModule)c=q[f]=a.cjsModule.exports;else{if(f in q&&!a.usingExports)return h.onError(new Error(f+" has already been defined"));q[f]=c}}else if(f)c=q[f]=b;if(f)if(d=w[f]){for(b=0;b<d.length;b++)d[b].onDep(f,c);delete w[f]}if(B[a.waitId]){delete B[a.waitId];a.isDone=true;i.waitCount-=1;if(i.waitCount===0)Z=[]}}function ia(a,b,c,d){a=k(a,d);var f=a.name,j=a.fullName,o={},m={waitId:f||ua+va++,depCount:0,depMax:0,prefix:a.prefix,name:f,
+fullName:j,deps:{},depArray:b,callback:c,onDep:function(ja,wa){if(!(ja in m.deps)){m.deps[ja]=wa;m.depCount+=1;m.depCount===m.depMax&&Y(m)}}},u,s;if(j){if(j in q||v[j]===true)return;z[j]=true;v[j]=true;i.jQueryDef=j==="jquery"}for(c=0;c<b.length;c++)if(u=b[c]){u=k(u,f?a:d);s=u.fullName;b[c]=s;if(s==="require")m.deps[s]=ga(a);else if(s==="exports"){m.deps[s]=q[j]={};m.usingExports=true}else if(s==="module"){m.cjsModule=u=m.deps[s]={id:f,uri:f?i.nameToUrl(f,null,d):undefined};u.setExports=n(u)}else if(s in
+q&&!(s in B))m.deps[s]=q[s];else if(!o[s]){m.depMax+=1;ha(u);(w[s]||(w[s]=[])).push(m);o[s]=true}}if(m.depCount===m.depMax)Y(m);else{B[m.waitId]=m;Z.push(m);i.waitCount+=1}}function J(a){ia.apply(null,a);v[a[0]]=true}function ka(a){if(!i.jQuery)if((a=a||(typeof jQuery!=="undefined"?jQuery:null))&&"readyWait"in a){i.jQuery=a;J(["jquery",[],function(){return jQuery}]);if(i.scriptCount){a.readyWait+=1;i.jQueryIncremented=true}}}function la(a,b){if(!a.isDone){var c=a.fullName,d=a.depArray,f,j;if(c){if(b[c])return q[c];
+b[c]=true}for(j=0;j<d.length;j++)(f=d[j])&&!a.deps[f]&&B[f]&&a.onDep(f,la(B[f],b));return c?q[c]:undefined}}function $(){var a=t.waitSeconds*1E3,b=a&&i.startTime+a<(new Date).getTime();a="";var c=false,d=false,f;if(!(i.pausedCount>0)){if(t.priorityWait)if(p())C();else return;for(f in v)if(!(f in F)){c=true;if(!v[f])if(b)a+=f+" ";else{d=true;break}}if(c||i.waitCount){if(b&&a){f=new Error("require.js load timeout for modules: "+a);f.requireType="timeout";f.requireModules=a;return h.onError(f)}if(d||
+i.scriptCount){if(A||ma)setTimeout($,50)}else if(i.waitCount){for(D=0;a=Z[D];D++)la(a,{});$()}else h.checkReadyState()}}}function na(a,b){var c=b.name,d=b.fullName,f;if(!(d in q||d in v)){G[a]||(G[a]=q[a]);v[d]||(v[d]=false);f=function(j){require.onPluginLoad&&require.onPluginLoad(i,a,c,j);Y({prefix:b.prefix,name:b.name,fullName:b.fullName,callback:function(){return j}});v[d]=true};f.fromText=function(j,o){var m=K;i.loaded[j]=false;i.scriptCount+=1;if(m)K=false;eval(o);if(m)K=true;i.completeLoad(j)};
+G[a].load(c,ga(b.parentMap,true),f,t)}}function xa(a){if(a.prefix&&a.name.indexOf("__$p")===0&&q[a.prefix])a=k(a.originalName,a.parentMap);var b=a.prefix,c=a.fullName;if(!(z[c]||v[c])){z[c]=true;if(b)if(q[b])na(b,a);else{if(!L[b]){L[b]=[];(w[b]||(w[b]=[])).push({onDep:function(d){if(d===b){var f,j=L[b];for(d=0;d<j.length;d++){f=j[d];na(b,k(f.originalName,f.parentMap))}delete L[b]}}})}L[b].push(a)}else h.load(i,c,a.url)}}var i,C,t={waitSeconds:7,baseUrl:r.baseUrl||"./",paths:{},pkgs:{}},M=[],z={require:true,
+exports:true,module:true},X={},q={},v={},B={},Z=[],va=0,w={},G={},L={},aa=0,S={};C=function(){var a,b,c;aa+=1;if(i.scriptCount<=0)i.scriptCount=0;for(;M.length;){a=M.shift();if(a[0]===null)return h.onError(new Error("Mismatched anonymous require.def modules"));else J(a)}if(!t.priorityWait||p())for(;i.paused.length;){c=i.paused;i.pausedCount+=c.length;i.paused=[];for(b=0;a=c[b];b++)xa(a);i.startTime=(new Date).getTime();i.pausedCount-=c.length}aa===1&&$();aa-=1};i={contextName:e,config:t,defQueue:M,
+waiting:B,waitCount:0,specified:z,loaded:v,urlMap:X,scriptCount:0,urlFetched:{},defined:q,paused:[],pausedCount:0,plugins:G,managerCallbacks:w,makeModuleMap:k,normalize:l,configure:function(a){var b,c,d;if(a.baseUrl)if(a.baseUrl.charAt(a.baseUrl.length-1)!=="/")a.baseUrl+="/";b=t.paths;d=t.pkgs;W(t,a,true);if(a.paths){for(c in a.paths)c in F||(b[c]=a.paths[c]);t.paths=b}if((b=a.packagePaths)||a.packages){if(b)for(c in b)c in F||ea(d,b[c],c);a.packages&&ea(d,a.packages);t.pkgs=d}if(a.priority){c=i.requireWait;
+i.requireWait=false;i.takeGlobalQueue();C();i.require(a.priority);C();i.requireWait=c;t.priorityWait=a.priority}if(a.deps||a.callback)i.require(a.deps||[],a.callback);a.ready&&h.ready(a.ready)},isDefined:function(a,b){return k(a,b).fullName in q},require:function(a,b,c){if(typeof a==="string"){if(h.get)return h.get(i,a,b);c=b;b=k(a,c);a=q[b.fullName];if(a===undefined)return h.onError(new Error("require: module name '"+b.fullName+"' has not been loaded yet for context: "+e));return a}ia(null,a,b,c);
+if(!i.requireWait)for(;!i.scriptCount&&i.paused.length;)C()},takeGlobalQueue:function(){if(T.length){ya.apply(i.defQueue,[i.defQueue.length-1,0].concat(T));T=[]}},completeLoad:function(a){var b;for(i.takeGlobalQueue();M.length;){b=M.shift();if(b[0]===null){b[0]=a;break}else if(b[0]===a)break;else{J(b);b=null}}b?J(b):J([a,[],a==="jquery"&&typeof jQuery!=="undefined"?function(){return jQuery}:null]);v[a]=true;ka();if(h.isAsync)i.scriptCount-=1;C();h.isAsync||(i.scriptCount-=1)},toUrl:function(a,b){var c=
+a.lastIndexOf("."),d=null;if(c!==-1){d=a.substring(c,a.length);a=a.substring(0,c)}return i.nameToUrl(a,d,b)},nameToUrl:function(a,b,c){var d,f,j,o,m=i.config;if(a.indexOf("./")===0||a.indexOf("../")===0){c=c&&c.url?c.url.split("/"):[];c.length&&c.pop();c=c.concat(a.split("/"));g(c);b=c.join("/")+(b?b:h.jsExtRegExp.test(a)?"":".js")}else{a=l(a,c);if(h.jsExtRegExp.test(a))b=a+(b?b:"");else{d=m.paths;f=m.pkgs;c=a.split("/");for(o=c.length;o>0;o--){j=c.slice(0,o).join("/");if(d[j]){c.splice(0,o,d[j]);
+break}else if(j=f[j]){a=a===j.name?j.location+"/"+j.main:j.location+"/"+j.lib;c.splice(0,o,a);break}}b=c.join("/")+(b||".js");b=(b.charAt(0)==="/"||b.match(/^\w+:/)?"":m.baseUrl)+b}}return m.urlArgs?b+((b.indexOf("?")===-1?"?":"&")+m.urlArgs):b}};i.jQueryCheck=ka;i.resume=C;return i}function za(){var e,g,l;if(N&&N.readyState==="interactive")return N;e=document.getElementsByTagName("script");for(g=e.length-1;g>-1&&(l=e[g]);g--)if(l.readyState==="interactive")return N=l;return null}var Aa=/(\/\*([\s\S]*?)\*\/|\/\/(.*)$)/mg,
+Ba=/require\(["']([^'"\s]+)["']\)/g,qa=/^\.\//,fa=/\.js$/,da=Object.prototype.toString,x=Array.prototype,sa=x.slice,ya=x.splice,A=!!(typeof window!=="undefined"&&navigator&&document),ma=!A&&typeof importScripts!=="undefined",Ca=A&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,oa=typeof opera!=="undefined"&&opera.toString()==="[object Opera]",ua="_r@@",F={},H={},T=[],N=null,Da=false,K=false,h;x={};var ba,r,I,U,y,O,P,D,ca,pa,E;if(typeof require!=="undefined")if(Q(require))return;
+else x=require;h=require=function(e,g,l){var k="_",p;if(!V(e)&&typeof e!=="string"){p=e;if(V(g)){e=g;g=l}else e=[]}if(p&&p.context)k=p.context;l=H[k]||(H[k]=ra(k));p&&l.configure(p);return l.require(e,g)};h.version="0.24.0";h.isArray=V;h.isFunction=Q;h.mixin=W;h.jsExtRegExp=/^\/|:|\?|\.js$/;r=h.s={contexts:H,skipAsync:{},isPageLoaded:!A,readyCalls:[]};if(h.isAsync=h.isBrowser=A){I=r.head=document.getElementsByTagName("head")[0];if(U=document.getElementsByTagName("base")[0])I=r.head=U.parentNode}h.onError=
+function(e){throw e;};h.load=function(e,g,l){var k=e.contextName,p=e.urlFetched,n=e.loaded;Da=false;n[g]||(n[g]=false);if(!p[l]){e.scriptCount+=1;h.attach(l,k,g);p[l]=true;if(e.jQuery&&!e.jQueryIncremented){e.jQuery.readyWait+=1;e.jQueryIncremented=true}}};define=h.def=function(e,g,l){var k;if(typeof e!=="string"){l=g;g=e;e=null}if(!h.isArray(g)){l=g;g=[]}if(!e&&!g.length&&h.isFunction(l))if(l.length){l.toString().replace(Aa,"").replace(Ba,function(p,n){g.push(n)});g=["require","exports","module"].concat(g)}if(K){k=
+ba||za();if(!k)return h.onError(new Error("ERROR: No matching script interactive for "+l));e||(e=k.getAttribute("data-requiremodule"));k=H[k.getAttribute("data-requirecontext")]}(k?k.defQueue:T).push([e,g,l])};define.amd={multiversion:true,plugins:true};h.execCb=function(e,g,l){return g.apply(null,l)};h.onScriptLoad=function(e){var g=e.currentTarget||e.srcElement,l;if(e.type==="load"||Ca.test(g.readyState)){N=null;e=g.getAttribute("data-requirecontext");l=g.getAttribute("data-requiremodule");H[e].completeLoad(l);
+g.detachEvent&&!oa?g.detachEvent("onreadystatechange",h.onScriptLoad):g.removeEventListener("load",h.onScriptLoad,false)}};h.attach=function(e,g,l,k,p){var n;if(A){k=k||h.onScriptLoad;n=document.createElement("script");n.type=p||"text/javascript";n.charset="utf-8";n.async=!r.skipAsync[e];n.setAttribute("data-requirecontext",g);n.setAttribute("data-requiremodule",l);if(n.attachEvent&&!oa){K=true;n.attachEvent("onreadystatechange",k)}else n.addEventListener("load",k,false);n.src=e;ba=n;U?I.insertBefore(n,
+U):I.appendChild(n);ba=null;return n}else if(ma){k=H[g];g=k.loaded;g[l]=false;importScripts(e);k.completeLoad(l)}return null};if(A){y=document.getElementsByTagName("script");for(D=y.length-1;D>-1&&(O=y[D]);D--){if(!I)I=O.parentNode;if(P=O.getAttribute("data-main")){if(!x.baseUrl){y=P.split("/");O=y.pop();y=y.length?y.join("/")+"/":"./";x.baseUrl=y;P=O.replace(fa,"")}x.deps=x.deps?x.deps.concat(P):[P];break}}}r.baseUrl=x.baseUrl;h.pageLoaded=function(){if(!r.isPageLoaded){r.isPageLoaded=true;ca&&clearInterval(ca);
+if(pa)document.readyState="complete";h.callReady()}};h.checkReadyState=function(){var e=r.contexts,g;for(g in e)if(!(g in F))if(e[g].waitCount)return;r.isDone=true;h.callReady()};h.callReady=function(){var e=r.readyCalls,g,l,k;if(r.isPageLoaded&&r.isDone){if(e.length){r.readyCalls=[];for(g=0;l=e[g];g++)l()}e=r.contexts;for(k in e)if(!(k in F)){g=e[k];if(g.jQueryIncremented){g.jQuery.ready(true);g.jQueryIncremented=false}}}};h.ready=function(e){r.isPageLoaded&&r.isDone?e():r.readyCalls.push(e);return h};
+if(A){if(document.addEventListener){document.addEventListener("DOMContentLoaded",h.pageLoaded,false);window.addEventListener("load",h.pageLoaded,false);if(!document.readyState){pa=true;document.readyState="loading"}}else if(window.attachEvent){window.attachEvent("onload",h.pageLoaded);if(self===self.top)ca=setInterval(function(){try{if(document.body){document.documentElement.doScroll("left");h.pageLoaded()}}catch(e){}},30)}document.readyState==="complete"&&h.pageLoaded()}h(x);if(h.isAsync&&typeof setTimeout!==
+"undefined"){E=r.contexts[x.context||"_"];E.requireWait=true;setTimeout(function(){E.requireWait=false;E.takeGlobalQueue();E.jQueryCheck();E.scriptCount||E.resume();h.checkReadyState()},0)}})();
View
62 lib/config.js
@@ -0,0 +1,62 @@
+var path = require('path')
+ ;
+
+module.exports = new function() {
+
+ this.MODELS_DIR_NAME = 'models';
+ this.VIEWS_DIR_NAME = 'views';
+ this.CONTROLLERS_DIR_NAME = 'controllers';
+ this.PLUGINS_DIR_NAME = 'plugins';
+ this.EXPORTS_DIR_NAME = 'exports';
+ this.CLIENT_DIR_NAME = 'client';
+ this.LOCALES_DIR_NAME = 'locales';
+
+ /* client specific dirs */
+ this.CLIENT_JS_DIR_NAME = 'js';
+ this.CLIENT_STATIC_DIR_NAME = 'static';
+ this.CLIENT_CSS_DIR_NAME = 'css';
+
+ this.CLIENT_VIEWS_DIR_NAME = 'views'
+
+ this.REQUIRE_JS_CONFIG_FILE_NAME = "require.config.json"
+
+ this.JADE_RUNTIME_FILE_NAME = 'jade-runtime-0.15.2.min.js'
+
+ /* namespace constants */
+ this.CONTROLLER_SUFFIX = '_controller';
+
+ /* RESTful methods names */
+ this.RESTFUL_METHODS = [
+ 'index'
+ , 'show'
+ , 'new'
+ , 'create'
+ , 'edit'
+ , 'update'
+ , 'destroy'
+ ];
+
+ this.NAMESPACE = 'rocket';
+
+ this.MODULE_NAME_REGEXP = '([a-zA-Z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*)';
+
+ this.VIEW_FILE_REGEXP = new RegExp(
+ [ this.MODULE_NAME_REGEXP
+ , '\.([a-zA-Z]+)'
+ ].join('')
+ );
+
+ this.CONTROLLER_NAME_REGEXP = new RegExp(
+ [ this.MODULE_NAME_REGEXP
+ , this.CONTROLLER_SUFFIX
+ ].join('')
+ );
+
+ this.EXPORTS_NAME_REGEXP = new RegExp(this.MODULE_NAME_REGEXP);
+
+ this.LOCALES_NAME_REGEXP = new RegExp(this.MODULE_NAME_REGEXP);
+
+ this.DEVELOPMENT_LISTEN_PORT = 3000
+ this.PRODUCTION_LISTEN_PORT = 80
+
+};
View
442 lib/controller.js
@@ -0,0 +1,442 @@
+/******************************************************************************
+ * Module dependencies
+ */
+var express = require('express')
+ , __ = require('express-resource')
+ , async = require('async')
+ , path = require('path')
+ , _ = require('underscore')
+ , lingo = require('lingo')
+ ;
+
+//project related dependencies
+var asyncFs = require('./util/async_fs')
+ , dadt = require('./util/dadt')
+ , config = require('./config')
+
+ , CONTROLLER_NAME_REGEXP = config.CONTROLLER_NAME_REGEXP
+ ;
+
+/******************************************************************************
+ * Rocket template name space
+ */
+var rocket_tmpl = {};
+
+ rocket_tmpl.header = function() {
+
+ var args = Array.prototype.slice.call(arguments)
+ , controller_name = args.shift()
+ ;
+
+ return [
+ "<script src='//cdnjs.cloudflare.com/ajax/libs/modernizr/2.0.6/modernizr.min.js'><\/script>"
+ , "<script> window.Modernizr || document.write('<script src=\"/js/rocket/vendors/modernizr-2.0.6.min.js\"><\\/script>')</script>"
+ , (global.require_configuration ? "<script> var require = " + global.require_configuration + "</script>": "")
+ , (controller_name ? "<script> require.ready = function() { require(['" + controller_name + "' + '_client' ], function(m) { m.init.apply(m" + (args.length > 0 ? ", " + JSON.stringify(args) : '') + ");} ); }</script>": "")
+ ].join('\n');
+ };
+
+ rocket_tmpl.footer = function() {
+ return [
+ "<script>"
+ , " Modernizr.load(["
+ , " {"
+ , " load : '//cdnjs.cloudflare.com/ajax/libs/require.js/0.24.0/require.min.js'"
+ , " , callback : function() {"
+ , " window.require || document.write('<script src=\"/js/rocket/vendors/require-0.24.0.min.js\"><\\/script>')"
+ , " }"
+ , " }"
+ , " ]);"
+ , "</script>"
+
+ ].join('\n')
+ };
+
+/******************************************************************************
+ * Destroy all the routes associated with a given controller
+ *
+ * @param app {Object} The `app` object as returned by express, connect, or
+ * rocket.
+ *
+ * @param routes_dadt {Object} The root of routes' dadt data structure.
+ *
+ * @param controller_name {String} The name of the controller
+ */
+function destroyControllerRoutes(app, routes_dadt, controller_name) {
+
+ var routes = routes_dadt.get(controller_name).get('routes')
+ ;
+
+ if (routes) {
+
+ for (var route in routes.values) {
+
+ app.remove(route);
+
+ }
+
+ }
+
+ delete app.resources[controller_info.name];
+ controller_info.set('routes', dadt.createNode());
+
+}
+
+/******************************************************************************
+ * Builds a wrapper function sending raw json as a response if no view is found
+ * or a rendered view
+ *
+ * @param controller_info {dadtNode} The dadtNode containing the controller
+ * info.
+ *
+ * @param method_func {Function} The method function.
+ */
+function buildWrapper(controller_info, method_func) {
+
+ return function(req, res, next) {
+
+ var view_file = controller_info.get('view')
+ , oSend = res.send
+ , oRender = res.render
+ ;
+
+ //check if we have a view & if that we do not have an XHR-Request.
+ //If the view is missing or if we have an XHR-Request, skip view rendering.
+ if (!req.xhr && view_file) {
+
+ //restore the original `res.send` function when `res.render` is called.
+ res.render = function() {
+
+ res.send = oSend;
+ oRender.apply(this, arguments);
+
+ };
+
+ //replace the original send function to be able to automatically render
+ //the wanted view.
+ res.send = function(obj) {
+
+ obj = obj || {};
+
+ obj.controller = obj.controller || controller_info.parent.get('name');
+
+ obj.rocket = obj.rocket || rocket_tmpl;
+
+ res.send = oSend;
+
+ res.render(view_file, obj);
+
+ };
+
+ }
+
+ method_func(req, res, next);
+
+ };
+
+}
+
+/******************************************************************************
+ * Builds and set up the routes of the given controller. Removing the previous
+ * routes if necessary.
+ *
+ * @param app {Object} The app object as returned by express, connect, or
+ * rocket.
+ *
+ * @param controller_info {Object} The dadt node containing the controller info.
+ *
+ * @param controller {Object} The controller object to route.
+ */
+function buildRoutes(app, controller_info, controller) {
+
+ var wrapped_funcs = {}
+ , split = []
+
+ , resource
+ , load
+ , name = controller_info.get('name')
+ ;
+
+ for (var key in controller) {
+
+ if (key.substr(0,1) === '_') {
+
+ if (key === '_load' && typeof controller[key] === 'function') {
+
+ //if the method name is `_load` and it is a function ... save it.
+
+ loader = controller[key];
+
+ }
+
+ //ignore keys beginning with a `_` unless it is `_load`
+ continue;
+
+ }
+
+ controller_info.setIfNone(key, dadt.createNode());
+ innerNode = controller_info.get(key);
+
+ if (typeof controller[key] === 'object' && controller[key] !== null) {
+
+ var verbs = _.functions(controller[key])
+ , route = (name === 'root' ? path.join('/', key) : path.join('/', name, key))
+ , param = ':' + lingo.en.singularize(name)
+ , route_param = path.join(route, param)
+ ;
+
+ for (var i = 0, ii = verbs.length; i < ii; i++) {
+
+
+ var current_verb = verbs[i]
+ , method = controller[key][current_verb]
+ ;
+
+ if (['get', 'post', 'put', 'del'].indexOf(current_verb) !== -1) {
+
+ innerNode.setIfNone(current_verb, dadt.createNode());
+
+ var wrapped = undefined
+ , current_verb_node = innerNode.get(current_verb)
+ ;
+
+ wrapped = buildWrapper(current_verb_node, method);
+
+ current_verb_node.set('handler', wrapped);
+
+ app[current_verb](route, wrapped);
+ app[current_verb](route_param, wrapped);
+
+ controller_info.get('routes').setIfNone(route, true);
+ controller_info.get('routes').setIfNone(route_param, true);
+
+ }
+
+ }
+
+ } else if(typeof controller[key] === 'function') {
+
+ var wrapped = undefined
+ , key_node = controller_info.get(key)
+ , route = (name === 'root' ? path.join('/', key) : path.join('/', name, key))
+ , param = ':' + lingo.en.singularize(name)
+ , route_param = path.join(route, param)
+ ;
+
+ wrapped = buildWrapper(innerNode, controller[key]);
+
+ innerNode.set('handler', wrapped);
+
+ //if the function is a custom controller method ...
+ if (['index', 'show', 'new', 'create', 'edit', 'update', 'destroy'].indexOf(key) === -1) {
+
+ app.all(route, wrapped);
+ app.all(route_param, wrapped);
+
+ controller_info.get('routes').setIfNone(route, true);
+ controller_info.get('routes').setIfNone(route_param, true);
+
+ } else {
+
+ app.remove(route);
+ app.remove(route_param);
+
+ wrapped_funcs[key] = wrapped;
+
+ }
+
+ }
+
+ }
+
+
+ if(name === 'root') {
+
+ resource = app.resource(wrapped_funcs);
+
+ } else {
+
+ resource = app.resource(name, wrapped_funcs);
+
+ }
+
+ if(typeof load !== 'undefined') {
+
+ resource.load(load);
+
+ }
+
+
+ for (var verb in resource.routes) {
+
+ for (var url in resource.routes[verb]) {
+
+ controller_info.get('routes').setIfNone(url, true);
+
+ }
+
+ }
+
+}
+
+/******************************************************************************
+ * Function called either when a new controller file is found or when a change
+ * is detected. It takes care of clearing the `require` cache and creating the
+ * controllers dadt node.
+ *
+ *
+ * @param app {Object} The app object as returned by express, connect, or
+ * rocket.
+ *
+ * @param controller_info {Object} The dadt node containing the controller info.
+ *
+ * @param controller_path {Object} The path of the current
+ * controller file.
+ *
+ * @param callback {Function} A callback of the form `function(err)`.
+ *
+ */
+function loadController() {
+
+ var args = Array.prototype.slice.call(arguments)
+
+ , app = args.shift()
+
+ , controller_info = args.shift()
+
+ , controller_path = args.shift()
+
+ , callback = args.pop()
+
+ , controller
+ ;
+
+
+ controller = require(controller_path);
+
+ buildRoutes(app, controller_info, controller);
+
+ if (callback) {
+ callback(null);
+ }
+}
+
+/******************************************************************************
+ * Sets up the listeners on the `controllers` directory and calls
+ * `loadController`.
+ *
+ * This function is also called each time a new controller file is found.
+ *
+ *
+ * @param app {Object} The app object as returned by express, connect, or
+ * rocket.
+ *
+ * @param routes_dadt {Object} The root of routes' dadt data structure.
+ *
+ * @param controller_file {Object} The FileEventEmitter object of the current
+ * controller file.
+ *
+ * @param matches {Array} Array of the matched patterns of the RegExp selecting
+ * this controller file.
+ *
+ *
+ * @param callback {Function} A callback of the form `function(err)`
+ *
+ */
+function setupController(app, routes_dadt, controller_file, matches, callback) {
+
+ var controller_name = matches[1]
+
+ , controller_path = controller_file.path
+
+ , reload
+ ;
+
+
+ routes_dadt.setIfNone(controller_name, dadt.createNode());
+
+ controller_info = routes_dadt.get(controller_name);
+
+ controller_info.set('routes', dadt.createNode());
+
+ controller_name = lingo.camelcase(controller_name.replace(/_/g, ' '));
+
+ controller_info.set('name', controller_name);
+
+ reload = async.apply(
+ loadController
+ , app
+ , controller_info
+ , controller_path
+ )
+
+ controller_file.on('change', function(curr, prev) {
+
+ if (curr.nlink > 0) {
+
+ if (require.cache[controller_path]) {
+
+ delete require.cache[controller_path];
+
+ }
+
+ destroyControllerRoutes(app, routes_dadt, controller_name);
+
+ reload();
+
+ }
+
+ });
+
+ controller_file.on('destroy', function() {
+
+ controller_file.unwatch();
+ destroyControllerRoutes(app, routes_dadt, controller_name)
+
+ });
+
+ reload(callback);
+
+}
+
+/******************************************************************************
+ * Setups the controllers, also watches the `controllers` directory for new
+ * files and calls `setupController` accordingly.
+ *
+ * @param app {Object} The app object as returned by express, connect, or
+ * rocket.
+ *
+ * @param routes_dadt {Object} The root of routes' dadt data structure.
+ *
+ * @param controllers {Object} The FileEventEmitter object of the `controllers`
+ * folder.
+ *
+ * @param callback {Function} A callback of the form `function(err)`
+ */
+exports.setup = function setup_controller() {
+
+ var args = Array.prototype.slice.call(arguments)
+
+ , app = args.shift()
+ , routes_dadt = args.shift()
+
+ , controllers = args.shift()
+
+ , callback = args.pop()
+ ;
+
+ app.rocket_routes = routes_dadt;
+
+ app.use(express.methodOverride());
+
+ asyncFs.mapDir(
+
+ controllers.path
+
+ , [ CONTROLLER_NAME_REGEXP , async.apply(setupController, app, routes_dadt) ]
+
+ , callback
+
+ );
+
+}
View
139 lib/export.js
@@ -0,0 +1,139 @@
+var dnode = require('dnode')
+ , async = require('async')
+ , lingo = require('lingo')
+ ;
+
+var asyncFs = require('./util/async_fs')
+
+ , config = require('./config')
+
+ , EXPORTS_NAME_REGEXP = config.EXPORTS_NAME_REGEXP
+ ;
+
+/******************************************************************************
+ * Watches the files in the exports directory for changes and, make them
+ * accessible through dnode
+ *
+ * @param exports_data {Object} The data structure containing the items to be
+ * exported.
+ *
+ * @param export_file {Object} The FileEventEmitter object of the current
+ * export file.
+ *
+ * @param matches {Array} Array of the matched patterns of the RegExp selecting
+ * this export file.
+ *
+ * @param callback {Function} A callback of the form `function(err)`
+ */
+function watchAndExport(exports_data, export_file, matches, callback) {
+
+ var module_name = matches[1]
+ , module_path = export_file.path
+ , export_name = lingo.camelcase(module_name.replace(/_/g, ' '))
+ ;
+
+ export_file.on('change', function() {
+
+ if (require.cache[module_path]) {
+
+ delete require.cache[module_path];
+
+ }
+
+ exports_data[module_name] = require(module_path);
+
+ });
+
+ export_file.on('destroy', function() {
+
+ delete exports_data[module_name];
+ export_file.unwatch();
+
+ });
+
+ if (require.cache[module_path]) {
+
+ delete require.cache[module_path];
+
+ }
+
+ exports_data[module_name] = require(module_path);
+
+ if (callback) {
+
+ callback(null);
+
+ }
+
+}
+
+/******************************************************************************
+ * Setups the dnode exports, also watches the `exports` directory for new
+ * files or changes and calls `setupExport` accordingly.
+ *
+ * @param app {Object} The app object as returned by express, connect, or
+ * rocket.
+ *
+ * @param exports_folder_file {Object} The FileEventEmitter object of the
+ * `exports` folder.
+ *
+ * @param callback {Function} A callback of the form `function(err)`
+ */
+exports.setup = function() {
+
+ var args = Array.prototype.slice.call(arguments)
+
+ , app = args.shift()
+ , exports_folder_file = args.shift()
+
+ , callback = args.pop()
+
+ , express_listen = app.listen
+ , exports_data = {}
+ ;
+
+ app.listen = function listen_export() {
+
+ var ret = express_listen.apply(this, arguments)
+ ;
+
+ dnode(function Exporter(remote, conn) {
+
+ var value
+ ;
+
+ for (var key in exports_data) {
+
+ value = exports_data[key];
+
+ switch (typeof value) {
+
+ case 'function':
+
+ this[key] = new value(remote, conn);
+ break;
+
+ default:
+
+ this[key] = value;
+
+ }
+
+ }
+
+ }).listen(app);
+
+ return ret;
+ }
+
+ asyncFs.mapDir(
+
+ exports_folder_file.path
+
+ , [ EXPORTS_NAME_REGEXP, async.apply(watchAndExport, exports_data) ]
+
+ , callback
+
+ );
+
+}
View
0 .../_project_generator/_project_generator.js → .../_project_generator/_project_generator.js
File renamed without changes.
View
0 libs/generators/_project_generator/index.js → lib/generator/_project_generator/index.js
File renamed without changes.
View
0 ...efault/client/static/apple-touch-icon.png → ...efault/client/static/apple-touch-icon.png
File renamed without changes
View
0 ...es/default/client/static/css/handheld.css → ...es/default/client/static/css/handheld.css
File renamed without changes.
View
0 ...lates/default/client/static/css/style.css → ...lates/default/client/static/css/style.css
File renamed without changes.
View
0 ...mplates/default/client/static/favicon.ico → ...mplates/default/client/static/favicon.ico
File renamed without changes.
View
0 libs/logo.png → ...plates/default/client/static/img/logo.png
File renamed without changes
View
0 ...es/default/controllers/root_controller.js → ...es/default/controllers/root_controller.js
File renamed without changes.
View
0 ...generator/templates/default/plugins/empty → ...generator/templates/default/exports/empty
File renamed without changes.
View
0 ...t_generator/templates/default/launcher.js → ...t_generator/templates/default/launcher.js
File renamed without changes.
View
0 ..._generator/templates/default/models/empty → ..._generator/templates/default/models/empty
File renamed without changes.
View
2 ...rator/templates/default/views/layout.jade → ...rator/templates/default/views/layout.jade
@@ -35,7 +35,7 @@ head
script(src="/static/modernizr-1.7.min.js")
body
- div!=body
+ !=body
//- Javascript at the bottom for fast page loading
//- Grab JQuery Tools CDN's jQuery. fall back to local if necessary
View
1 lib/generator/_project_generator/templates/default/views/root/root.index.jade
@@ -0,0 +1 @@
+h3 Welcome to Node Rocket !
View
0 ...troller_generator/controller_generator.js → ...troller_generator/controller_generator.js
File renamed without changes.
View
0 .../generators/controller_generator/index.js → lib/generator/controller_generator/index.js
File renamed without changes.
View
18 lib/index.js
@@ -0,0 +1,18 @@
+var fs = require('fs')
+ , path = require('path')
+ , oo = require('oo')
+ , express = require('express')
+ ;
+
+var pkg_json_path = path.join(__dirname, '..', 'package.json')
+ , pkg_json = fs.readFileSync(pkg_json_path, 'utf8')
+ , pkg_json_info = JSON.parse(pkg_json)
+ ;
+
+module.exports = oo.extend({
+ version : pkg_json_info.version
+ , util : require('./util')
+ , createServer : require('./loader').createServer
+ , i18n : require('./locale').i18n
+ , _ : require('./locale')._
+}, express);
View
103 lib/loader.js
@@ -0,0 +1,103 @@
+var express = require('express')
+ , async = require('async')
+ ;
+
+var asyncFs = require('./util/async_fs')
+ , dadt = require('./util/dadt')
+
+ , config = require('./config')
+
+ , CLIENT_DIR_NAME = config.CLIENT_DIR_NAME
+ , CONTROLLERS_DIR_NAME = config.CONTROLLERS_DIR_NAME
+ , EXPORTS_DIR_NAME = config.EXPORTS_DIR_NAME
+ , VIEWS_DIR_NAME = config.VIEWS_DIR_NAME
+ , LOCALES_DIR_NAME = config.LOCALES_DIR_NAME
+
+ , DEVELOPMENT_LISTEN_PORT = config.DEVELOPMENT_LISTEN_PORT
+ , PRODUCTION_LISTEN_PORT = config.PRODUCTION_LISTEN_PORT
+ ;
+
+var client = require('./client')
+ , controller = require('./controller')
+ , export = require('./export')
+ , view = require('./view')
+ , locale = require('./locale')
+ ;
+
+/******************************************************************************
+ * createServer
+ */
+exports.createServer = function createServer_rocket() {
+
+ var args = Array.prototype.slice.call(arguments)
+ , app_dir = args.shift()
+
+ , callback = args.pop()
+
+ , middlewares = args.shift()
+
+ , app = express.createServer()
+ , original_listen = app.listen
+
+ , routes = dadt.createNode()
+ ;
+
+ app.listen = function() {
+
+ var args = Array.prototype.slice.call(arguments)
+ , port = (typeof args[0] === 'number' ? args.shift() : undefined)
+ ;
+
+ if (!port) {
+
+ if (process.env['NODE_ENV'] === 'production') {
+
+ port = PRODUCTION_LISTEN_PORT;
+
+ } else {
+
+ port = DEVELOPMENT_LISTEN_PORT;
+
+ }
+
+ }
+
+ args.unshift(port);
+
+ return original_listen.apply(app, args);
+
+ }
+
+ if (middlewares) {
+
+ for (var i = 0, ii = middlewares.length; i < ii; i++) {
+
+ app.use(middlewares[i]);
+
+ }
+
+ }
+
+ asyncFs.mapDir(
+
+ app_dir
+
+ , [
+
+ [ CLIENT_DIR_NAME , async.apply(client.setup, app) ]
+
+ , [ CONTROLLERS_DIR_NAME , async.apply(controller.setup, app, routes) ]
+
+ , [ EXPORTS_DIR_NAME , async.apply(export.setup, app) ]
+
+ , [ VIEWS_DIR_NAME , async.apply(view.setup, app, routes) ]
+
+ , [ LOCALES_DIR_NAME , async.apply(locale.setup) ]
+
+ ]
+
+ , function(err) { callback(err, app); }
+
+ );
+
+}
View
114 lib/locale.js
@@ -0,0 +1,114 @@
+var async = require('async')
+ , i18n = require('jade-i18n')
+ ;
+
+var asyncFs = require('./util/async_fs')
+
+ , config = require('./config')
+ , LOCALES_NAME_REGEXP = config.LOCALES_NAME_REGEXP
+ ;
+
+exports.i18n = i18n;
+
+exports._ = i18n.helpers._;
+
+/******************************************************************************
+ * Setup phrases as defined by `locale_file`, watches `locale_file` for
+ * changes and makes changes accordingly. Also removes all the phrases on file
+ * deletion.
+ *
+ * @param locale_file {Object} The FileEventEmitter object of the current locale
+ * file.
+ *
+ * @param matches {Array} Array of the matched patterns of the RegExp selecting
+ * this locale file.
+ *
+ * @param callback {Function} A callback of the form `function(err)`
+ */
+function setupLocale(locale_file, matches, callback) {
+
+ var locale = require(locale_file.path)
+ , lang = matches[1]
+ , phrase
+ ;
+
+ function setupPhrases(locale) {
+
+ var translation
+ ;
+
+ for (var phrase in locale) {
+
+ translation = locale[phrase];
+
+ i18n.phrase(lang, phrase, translation);
+
+ }
+
+ }
+
+ function removePhrases(locale) {
+
+ for (var phrase in locale) {
+
+ i18n.phrase(lang, phrase, undefined);
+
+ }
+
+ }
+
+ locale_file.on('change', function(curr, prev) {
+
+ delete require.cache[locale_file.path];
+
+ removePhrases(locale);
+
+ locale = require(locale_file.path);
+
+ setupPhrases(locale);
+
+ });
+
+ locale_file.on('destroy', function(curr, prev) {
+
+ delete require.cache[locale_file.path];
+
+ removePhrases(locale);
+
+ });
+
+ setupPhrases(locale);
+
+ if (callback) { callback(null) };
+
+}
+
+/******************************************************************************
+ * Setups the localized strings, also watches the `locales` directory for new
+ * files or changes and calls `setupLocale` accordingly.
+ *
+ * @param locales_folder_file {Object} The FileEventEmitter object of the
+ * `locales` folder.
+ *
+ * @param callback {Function} A callback of the form `function(err)`
+ */
+exports.setup = function() {
+
+ var args = Array.prototype.slice.call(arguments)
+
+ , locales_folder_file = args.shift()
+
+ , callback = args.pop()
+ ;
+
+ asyncFs.mapDir(
+
+ locales_folder_file.path
+
+ , [ LOCALES_NAME_REGEXP, setupLocale ]
+
+ , callback
+
+ );
+
+}
View
0 ...plates/default/client/static/img/logo.png → lib/logo.png
File renamed without changes
View
486 lib/util/async_fs.js
@@ -0,0 +1,486 @@
+/******************************************************************************
+ * Module dependencies
+ */
+var async = require('async')
+ , fs = require('fs')
+ , path = require('path')
+ ;
+
+var FileEventEmitter = require('./file_Event_emitter')
+
+/******************************************************************************
+ * Traverses the directory defined by `dir_path` and recursively
+ * watches for any addition, removal, or modification of files, emitting a
+ * `change` event accordingly.
+ *
+ * @param dir_path {String} The path of the root of the directory tree we want
+ * to watch.
+ *
+ * @returns {FileEventEmitter} the FileEventEmitter instance of the root
+ * directory.
+ *
+ */
+exports.watchTree = function watchTree_asyncFs(dir_path) {
+
+ var dir_event_emitter = new FileEventEmitter(dir_path)
+ ;
+
+ fs.readdir(dir_path, function(err, files) {
+
+ if (err) {
+
+ throw err;
+
+ }
+
+ async.forEach(
+
+ files
+
+ , function iterator(filename, callback) {
+
+ var file_path = path.join(dir_path, filename)
+ , emitter
+ ;
+
+ fs.stat(file_path, function(err, stats) {
+
+ if (err) {
+
+ callback(err);
+ return;
+
+ }
+
+ console.log('--- watching ' + file_path)
+
+ if (stats.isDirectory()) {
+
+ emitter = watchTree_asyncFs(file_path);
+
+ } else {
+
+ emitter = new FileEventEmitter(file_path);
+
+ }
+
+ emitter.on('change', function() {
+
+ dir_event_emitter.emit('change');
+
+ });
+
+ emitter.on('destroy', function() {
+
+ emitter.unwatch();
+
+ });
+
+ callback(null);
+
+ });
+
+ }
+
+ , function callback(err) {
+
+ if (err) { throw err; }
+
+ }
+
+ );
+
+ })
+
+ return dir_event_emitter;
+
+}
+
+/******************************************************************************
+ * Test if the matched file is a directory. Meant to be used with mapDir as a
+ * test passed to the iterator.
+ *
+ * @param filename {String} The filename of the current file to test
+ * @param file_path {String} The path of the current file to test
+ * @param callback {Function} a function of the form `function(err, matches)` where
+ *
+ * * `err` is your usual calback error parameter
+ *
+ * * `matches` is a parameter, to be passed to `continuation`. An
+ * undefined `matches` argument means a negative match and thus tells
+ *
+ * * the iterator **not** to call the continuation.
+ *
+ */
+exports.isDirTest = function isDirTest_asyncFs(filename, file_path, callback) {
+
+ fs.stat(file_path, function(err, stats) {
+
+ if (err) {
+
+ callback(err);
+
+ } else {
+
+ if (stats.isDirectory()) {
+
+ callback(null, filename);
+
+ } else {
+
+ callback(null);
+
+ }
+
+ }
+
+ });
+
+}
+
+/******************************************************************************
+ * Watch for changes on `filename`. The callback `listener` will be called with
+ * the specified `arguments...` each time the file is *accessed*.
+ *
+ * This function also returns a continuation function with the arguments
+ * already applied.
+ *
+ * Any arguments passed to the returned function are appended to the arguments
+ * originally passed to apply.
+ *
+ * Finally, when called by `fs.watchFile`, `prev` and `curr` can be
+ * respectively accessed through `this.prev` and `this.curr`.
+ *
+ * @param filename The filename of the file to watch. Support watching multiple
+ * files by providing an array of filename.
+ *
+ * @param listener The function you want to eventually apply all arguments to.
+ *
+ * @param arguments... Any number of arguments to automatically apply when the
+ * continuation is called.
+ */
+exports.applyAndWatchFile = function applyAndWatchFile() {
+
+ var args = Array.prototype.slice.apply(arguments)
+
+ , filename = args.shift()
+ , listener = args.shift()
+
+ , context = {}
+
+ , continuation = function() {
+
+ var cont_args = Array.prototype.slice.apply(arguments)
+ ;
+
+ if
+ ( cont_args.length === 2
+ && cont_args[0] instanceof fs.Stat
+ && cont_args[1] instanceof fs.Stat
+ ){
+
+ context.curr = cont_args[0];
+ context.prev = cont_args[1];
+
+ } else {
+
+ Array.prototype.unshift.apply(cont_args, args);
+
+ }
+
+ listener.apply(context, cont_args)
+
+ }
+ ;
+
+ if (typeof filename === 'object'
+ && Array.isArray(filename)
+ ){
+
+ async.forEach(
+
+ filename
+
+ , function(single_filename){
+
+ continuation(single_filename, continuation);
+
+ }
+
+ );
+
+ } else {
+
+ fs.watchFile(filename, continuation);
+
+ }
+
+ return continuation;
+
+}
+
+/******************************************************************************
+ * Reads the content of the directory specified by `path` and applies `iterator`
+ * to each file.
+ *
+ * @param path The path of the directory.
+ * @param iterator An iterator function of the form `function(file, callback)`
+ * @param callback A callback of the form `function(err)`.
+ */
+exports.forEachFile = function forEachFile(path, iterator, callback) {
+
+ async.waterfall(
+ [
+ function(callback) { fs.readdir(path, callback); }
+
+ , function (files, callback) {
+
+ async.forEach(files, iterator, callback);
+
+ }
+ ]
+ , callback
+ );
+
+}
+
+/******************************************************************************
+ * Reads the content of the directory specified by `path` and applies `iterator`
+ * to each file in series.
+ *
+ * The next iterator is only called once the current one has completed.
+ *
+ * @param path The path of the directory.
+ * @param iterator An iterator function of the form `function(file, callback)`.
+ * @param callback A callback of the form `function(err)`.
+ */
+exports.forEachFileSeries = function forEachFileSeries(path, iterator, callback) {
+
+ async.waterfall(
+
+ async.apply(fs.readdir, path)
+
+ , function (files, callback) {
+
+ async.forEachSeries(files, iterator, callback);
+
+ }
+
+ , callback
+ );
+
+}
+
+/******************************************************************************
+ * Reads the specified directory and iterates through its children files and
+ * applies the iterator if the filename matched the associated filter.
+ *
+ * Also watches the directory for new files and applies the iterators according
+ * to the filters to any new found file.
+ *
+ * @param dir_path {String} The path of the directory on which to apply this
+ * function.
+ *
+ * @param filters {Array} An array representing a 2-tuple of
+ * `[filter, continuation]`
+ *
+ * where
+ *
+ * * `filter` is either a {RegExp}, a {String} representing a {RegExp} or
+ * a function of the form `function(filename, callback)` where
+ *
+ * * `filename` is the current filename to test
+ *
+ * * `file_path` is the path of the current file to test
+ *
+ * * `callback` is a function of the form `function(err, matches)` where
+ *
+ * * `err` is your usual calback error parameter
+ *
+ * * `matches` is a parameter, to be passed to `continuation`. An
+ * undefined `matches` argument means a negative match and thus tells
+ * the iterator **not** to call the continuation.
+ *
+ * Alternatively, this param can also be an array of `filter` defined as
+ * above.
+ *
+ * * `continuation` is a {Function} of the form
+ *
+ * `function(file_events, matches, callback)` where
+ *
+ * ** `file_event` is a {FileEventEmitter} of the selected file.
+ *
+ * ** `matches` is an {Array} of the matched patterns of the RegExp selecting
+ * file, or the value returned by the user supplied test.
+ *
+ * ** `callback` is an optional {Function} pointed to the passed
+ * callback.
+ *
+ * @param callback {Function} A callback of the form `function(err)`
+ */
+exports.mapDir = function mapDir() {
+
+ var args = Array.prototype.slice.call(arguments)
+
+ , dir_path = args.shift()
+ , filters = (Array.isArray(args[0][0]) ? args.shift() : [args.shift()])
+ , callback = args.pop()
+
+ , emitter = new FileEventEmitter(dir_path)
+ , snapshot
+ ;
+
+ async.waterfall(
+
+ [
+
+ async.apply(fs.readdir, dir_path)
+
+ , function (files, callback) {
+
+ snapshot = files;
+
+ if (files) {
+
+ async.forEach(files, iterator, callback);
+
+ } else {
+
+ callback(null);
+
+ }
+
+ }
+ ]
+
+ , callback
+
+ );
+
+ emitter.on('change', function(curr, prev) {
+
+ var nlink_diff = curr.nlink - prev
+ , diff = []
+ ;
+
+ if(curr.nlink < prev.nlink) { return; }
+
+ async.waterfall(
+ [
+
+ async.apply(fs.readdir, dir_path)
+
+ , function(files, callback) {
+
+ for (var i = 0, ii = files.length; i < ii; i++) {
+
+ var file = files[i];
+
+ if (snapshot.indexOf(file) === -1) {
+
+ diff.push(file);
+
+ if (--nlink_diff > 0) {
+
+ continue;
+
+ } else {
+
+ break;
+
+ }
+
+ }
+
+ }
+
+ snapshot = files;
+
+ async.forEach(diff, iterator, callback);
+
+ }
+ ]
+ , function(err) {
+
+ if (err) {
+
+ throw err;
+
+ }
+
+ }
+
+ );
+
+ });
+
+ return emitter;
+
+ /*************************************************************************/
+
+ function iterator(filename, callback) {
+
+ async.forEach(
+
+ filters
+
+ , function(filter, callback) {
+
+ var test
+ , regexp
+ , matches
+
+ , continuation = filter[1]
+
+ , file_path = path.join(dir_path, filename)
+ , emitter
+ ;
+
+ if (typeof filter[0] === 'string') {
+
+ regexp = new RegExp(filter[0]);
+ matches = regexp.exec(filename);
+
+ checkAndContinue(null, matches);
+
+ } else if (filter[0] instanceof RegExp) {
+
+ regexp = filter[0];
+ matches = regexp.exec(filename);
+ checkAndContinue(null, matches);
+
+ } else {
+
+ test = filter[0]
+ test(filename, file_path, checkAndContinue);
+
+ }
+
+ function checkAndContinue(err, matches) {
+
+ if (err) {
+
+ callback(err);
+
+ } else if (matches) {
+
+ emitter = new FileEventEmitter(file_path);
+
+ continuation(emitter, matches, callback);
+
+ } else {
+
+ callback(null);
+
+ }
+
+ }
+
+ }
+
+ , callback
+ );
+
+ }
+
+}
View
95 lib/util/dadt.js
@@ -0,0 +1,95 @@
+var events = require('events');
+
+/**
+ * Create a Dynamic ADT node, initializes it with according to `obj` and returns
+ * it.
+ *
+ * @param obj An object containing initial variables to be set.
+ *
+ * @returns The instantiated Node.
+ */
+exports.createNode = function(obj) {
+
+
+ /**
+ * Node constructor.
+ *
+ * @param obj An object containing initial variables to be set.
+ */
+ function Node(obj) {
+
+ this.values = new Object(obj);
+
+ }
+
+ //Inherits prototype from `events.EventEmitter`
+ Node.prototype = new Object(events.EventEmitter.prototype);
+
+ /**
+ * Get the value of the variable named `key`.
+ *
+ * @param key The `key` of the wanted variable.
+ */
+ Node.prototype.get = function get_Node(key) {
+
+ return this.values[key];
+
+ }
+
+ /**
+ * Set the variable named `key` to `value`.
+ *
+ * @param key The name of the wanted variable.
+ * @param value The value to set the variable to.
+ *
+ * @returns `this`
+ */
+ Node.prototype.set = function set_Node(key, value) {
+
+ var old_value = this.values[key]
+ ;
+
+ this.values[key] = value;
+
+ if (value instanceof Node) {
+
+ value['parent'] = this;
+
+ }
+
+ this.emit('change', this, key, value, old_value);
+ this.emit('change:' + key, this, value, old_value);
+
+ return this;
+
+ }
+
+ /**
+ * Set the variable named `key` to `value` if and only if it doesn't already
+ * exists.
+ *
+ * @param key The name of the wanted variable.
+ * @param value The value to set the variable to.
+ *
+ * @returns `this`
+ */
+ Node.prototype.setIfNone = function setIfNone_Node(key, value) {
+
+ if (!this.values[key]) {
+
+ return this.set(key, value);
+
+ } else {
+
+ return this;
+
+ }
+
+ }
+
+ //inherit from EventEmitter
+ events.EventEmitter.call(this);
+
+ return new Node(obj);
+
+}
View
90 lib/util/file_event_emitter.js
@@ -0,0 +1,90 @@
+var events = require('events')
+ , fs = require('fs')
+ ;
+
+var cache = [];
+
+//Inherits the prototype from `events.EventEmitter`
+FileEventEmitter.prototype = Object.create(events.EventEmitter.prototype);
+
+/*******************************************************************************
+ * Destroys the FileEventEmmitter instance and stops watching the file.
+ */
+FileEventEmitter.prototype.unwatch = function unwatch_FileEventEmitter() {
+ fs.unwatchFile(this.path);
+}
+
+/******************************************************************************
+ * FileEventEmitter constructor
+ *
+ * Watches the specified file and emit events such that:
+ *
+ * * it emits a `access` event when the file is accessed
+ * * it emits a `destroy` event when the file is deleted
+ * * it emits a `change` event when the file is modified
+ *
+ * If the watched file is a directory FileEventEmitter emits events such that:
+ *
+ * * it emits a `add` event when a file is added to the directory
+ * * it emits a `delete` event when a file deleted from the directory
+ *
+ * @extends events.EventEmitter
+ *
+ * @param file_path {String} The path of the file we want to watch.
+ * @api public
+ */
+function FileEventEmitter(file_path) {
+
+ var that = this
+ ;
+
+ if (cache[file_path]) {
+
+ return cache[file_path];
+
+ }
+
+ events.EventEmitter.call(this);
+
+ fs.watchFile(file_path, fileEventListener);
+
+ this.path = file_path;
+
+ cache[file_path] = this;
+
+ /**************************************************************************/
+
+ function fileEventListener(curr, prev) {
+
+ that.emit('access', curr, prev);
+
+ if (curr.nlink === 0) {
+
+ that.emit('destroy', curr, prev);
+
+ }
+
+ if (+curr.mtime != +prev.mtime) {
+
+ if (curr.isDirectory() && prev.isDirectory()) {
+
+ if (curr.nlink > prev.nlink) {
+
+ that.emit('add', curr, prev);
+
+ } else if (curr.nlink < prev.nlink) {
+
+ that.emit('delete', curr, prev);
+
+ }
+
+ }
+
+ that.emit('change', curr, prev);
+
+ }
+
+ }
+
+}
+module.exports = FileEventEmitter;
View
7 lib/util/index.js
@@ -0,0 +1,7 @@
+module.exports = {
+ asyncFs : require('./async_fs')
+ , dadt : require('./dadt')
+ , FileEventEmitter : require('./file_event_emitter')
+ , namespace : require('./namespace')
+ , tmpdir : require('./tmpdir')
+}
View
0 libs/utils/namespace.js → lib/util/namespace.js
File renamed without changes.
View
128 lib/util/tmpdir.js
@@ -0,0 +1,128 @@
+var fs = require('fs')
+ , path = require('path')
+ , rimraf = require('rimraf')
+ ;
+
+var TMPDIR = process.env['TMPDIR'] || '/tmp'
+ , PID = process.pid
+ , MODE = 0755
+ ;
+
+var counter = 0
+ ;
+
+/******************************************************************************
+ * Initialization
+ */
+var proc_tmpdir_path = path.join(TMPDIR, '' + PID)
+ ;
+
+//clears the process tmpdir if it already exists
+try {
+
+ rimraf.sync(proc_tmpdir_path);
+
+} catch(err) {
+
+ if (err.code !== 'ENOENT') {
+
+ throw err;
+
+ }
+
+}
+
+//creates a new process tmpdir
+fs.mkdirSync(proc_tmpdir_path, MODE);
+
+//exports the proc_tmpdir_path
+exports.path = proc_tmpdir_path;
+
+
+/******************************************************************************
+ * ChildTmpdir constructor
+ *
+ * @param id {Number} The id of the ChildTmpdir
+ */
+function ChildTmpdir(id) {
+
+ if (typeof id === 'undefined') {
+
+ throw 'ChildTmpdir needs a defined id';
+
+ }
+
+ this.id = id;
+ this.path = path.join(proc_tmpdir_path, '' + id);
+
+}
+
+/**
+ * Clears the tmpdir by removing it and re-creating it.
+ *
+ * @param callback {function} A callback of the form `function(err)`
+ */
+ChildTmpdir.prototype.clear = function(callback) {
+
+ return clear_tmpdir(this.id, callback);
+
+}
+
+/******************************************************************************
+ * Makes a unique directory in the current process' tmpdir and returns its
+ * path.
+ *
+ * @param mode {Number} (optional) The mode of the wanted directory. Defaults
+ * to 0750 or [drwxr-x---]
+ *
+ * @returns {String} The id of the created unique directory.
+ */
+function mkuniqueSync_tmpdir(mode) {
+
+ var id = counter++
+ , unique_dir_path = path.join(proc_tmpdir_path, '' + id)
+ ;
+
+ mode = mode || MODE
+
+
+
+ fs.mkdirSync(unique_dir_path, MODE);
+
+ return new ChildTmpdir(id);
+
+}
+exports.mkuniqueSync = mkuniqueSync_tmpdir;
+
+/******************************************************************************
+ * Clears the process tmpdir by removing it and re-creating it.
+ *
+ * @param callback {function} A callback of the form `function(err)`
+ */
+function clear_tmpdir() {
+
+ var args = Array.prototype.slice.call(arguments)
+
+ , callback = args.pop()
+
+ , dir_id = (typeof args[0] === 'undefined' ? '' : args.shift())
+
+ , dir_path = path.join(proc_tmpdir_path, '' + dir_id)
+ ;
+
+ rimraf(dir_path, function(err) {
+
+ if (err) {
+
+ callback(err);
+
+ } else {
+
+ fs.mkdir(dir_path, MODE, callback);
+
+ }
+
+ });
+
+}
+exports.clear = clear_tmpdir;
View
8,273 lib/vendors/r.js
8,273 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
140 lib/view.js
@@ -0,0 +1,140 @@
+
+var async = require('async')
+ , lingo = require('lingo')
+ , jade = require('jade')
+ , path = require('path')
+ ;
+
+var dadt = require('./util/dadt')
+ , asyncFs = require('./util/async_fs')
+ , config = require('./config')
+ , VIEW_FOLDER_NAME_REGEXP = config.MODULE_NAME_REGEXP
+ , VIEW_FILE_REGEXP = config.VIEW_FILE_REGEXP
+ ;
+
+/******************************************************************************
+ * Listens on discovered / new view directory and iteratively maps them to
+ * the dadt datastore
+ *
+ * @param app {Object} The app object as returned by express, connect, or
+ * rocket.
+ *
+ * @param routes_dadt {Object} The root of routes' dadt data structure.
+ *
+ * @param view_folder {Object} The FileEventEmitter object of the current
+ * view folder.
+ *
+ * @param matches {Array} Array of the matched patterns of the RegExp selecting
+ * this controller folder.
+ *
+ * @param callback {Function} A callback of the form `function(err)`
+ *
+ */
+function setupView() {
+
+ var args = Array.prototype.slice.call(arguments)
+ , app = args.shift()
+ , routes_dadt = args.shift()
+ , view_folder = args.shift()
+ , matches = args.shift()
+ , callback = args.pop()
+
+ , controller_name = matches
+
+ , controller_node
+ ;
+
+ lingo.camelcase(controller_name.replace(/_/g, ' '));
+
+ routes_dadt.setIfNone(controller_name, dadt.createNode());
+
+ controller_node = routes_dadt.get(controller_name);
+
+ asyncFs.mapDir(
+
+ view_folder.path
+
+ , [ VIEW_FILE_REGEXP , function(view_file, matches, callback) {
+
+ var split = matches['input'].split('.')
+ , current_node
+ ;
+
+ current_node = controller_node;
+
+ for (var i = 1, ii = split.length; i < ii - 1; i++) {
+
+ current_node.setIfNone(split[i], dadt.createNode());
+ current_node = current_node.get(split[i]);
+
+ }
+
+ current_node.set('view', view_file.path)
+
+ view_file.on('destroy', function() {
+
+ view_file.unwatch();
+ current_node.set('view', undefined);
+
+ });
+
+ if (callback) {
+
+ callback(null);
+
+ }
+
+ }]
+
+ , callback
+
+ )
+
+
+}
+
+/******************************************************************************
+ * Setups the views, also watches the `views` directory for new
+ * files and calls `setupView` accordingly.
+ *
+ * @param app {Object} The app object as returned by express, connect, or
+ * rocket.
+ *
+ * @param routes_dadt {Object} The root of routes' dadt data structure.
+ *
+ * @param views {Object} The FileEventEmitter object of the `views`
+ * folder.
+ *
+ * @param callback {Function} A callback of the form `function(err)`
+ */
+exports.setup = function setup_view() {
+
+ var args = Array.prototype.slice.call(arguments)
+
+ , app = args.shift()
+ , routes_dadt = args.shift()
+
+ , views = args.shift()
+
+ , callback = args.pop()
+ ;
+
+ app.configure(function() {
+
+ app.set("view engine", 'jade');
+ app.set("views", views.path);
+ app.register(".jade", jade);
+
+ });
+
+ asyncFs.mapDir(
+
+ views.path
+
+ , [ asyncFs.isDirTest , async.apply(setupView, app, routes_dadt) ]
+
+ , callback
+
+ );
+
+}
View
6 libs/generators/_project_generator/templates/default/client/js/root_client.js
@@ -1,6 +0,0 @@
-var dnode = require('dnode')
- , remote
- ;
-
-dnode.connect(function(r) { remote = r; });
-
View
13 libs/generators/_project_generator/templates/default/client/js/vendors/dd_belatedpng.js
@@ -1,13 +0,0 @@
-/**
-* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
-* Author: Drew Diller
-* Email: drew.diller@gmail.com
-* URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/
-* Version: 0.0.8a
-* Licensed under the MIT License: http://dillerdesign.com/experiment/DD_belatedPNG/#license
-*
-* Example usage:
-* DD_belatedPNG.fix('.png_bg'); // argument is a CSS selector
-* DD_belatedPNG.fixPng( someNode ); // argument is an HTMLDomElement
-**/
-var DD_belatedPNG={ns:"DD_belatedPNG",imgSize:{},delay:10,nodesFixed:0,createVmlNameSpace:function(){if(document.namespaces&&!document.namespaces[this.ns]){document.namespaces.add(this.ns,"urn:schemas-microsoft-com:vml")}},createVmlStyleSheet:function(){var b,a;b=document.createElement("style");b.setAttribute("media","screen");document.documentElement.firstChild.insertBefore(b,document.documentElement.firstChild.firstChild);if(b.styleSheet){b=b.styleSheet;b.addRule(this.ns+"\\:*","{behavior:url(#default#VML)}");b.addRule(this.ns+"\\:shape","position:absolute;");b.addRule("img."+this.ns+"_sizeFinder","behavior:none; border:none; position:absolute; z-index:-1; top:-10000px; visibility:hidden;");this.screenStyleSheet=b;a=document.createElement("style");a.setAttribute("media","print");document.documentElement.firstChild.insertBefore(a,document.documentElement.firstChild.firstChild);a=a.styleSheet;a.addRule(this.ns+"\\:*","{display: none !important;}");a.addRule("img."+this.ns+"_sizeFinder","{display: none !important;}")}},readPropertyChange:function(){var b,c,a;b=event.srcElement;if(!b.vmlInitiated){return}if(event.propertyName.search("background")!=-1||event.propertyName.search("border")!=-1){DD_belatedPNG.applyVML(b)}if(event.propertyName=="style.display"){c=(b.currentStyle.display=="none")?"none":"block";for(a in b.vml){if(b.vml.hasOwnProperty(a)){b.vml[a].shape.style.display=c}}}if(event.propertyName.search("filter")!=-1){DD_belatedPNG.vmlOpacity(b)}},vmlOpacity:function(b){if(b.currentStyle.filter.search("lpha")!=-1){var a=b.currentStyle.filter;a=parseInt(a.substring(a.lastIndexOf("=")+1,a.lastIndexOf(")")),10)/100;b.vml.color.shape.style.filter=b.currentStyle.filter;b.vml.image.fill.opacity=a}},handlePseudoHover:function(a){setTimeout(function(){DD_belatedPNG.applyVML(a)},1)},fix:function(a){if(this.screenStyleSheet){var c,b;c=a.split(",");for(b=0;b<c.length;b++){this.screenStyleSheet.addRule(c[b],"behavior:expression(DD_belatedPNG.fixPng(this))")}}},applyVML:function(a){a.runtimeStyle.cssText="";this.vmlFill(a);this.vmlOffsets(a);this.vmlOpacity(a);if(a.isImg){this.copyImageBorders(a)}},attachHandlers:function(i){var d,c,g,e,b,f;d=this;c={resize:"vmlOffsets",move:"vmlOffsets"};if(i.nodeName=="A"){e={mouseleave:"handlePseudoHover",mouseenter:"handlePseudoHover",focus:"handlePseudoHover",blur:"handlePseudoHover"};for(b in e){if(e.hasOwnProperty(b)){c[b]=e[b]}}}for(f in c){if(c.hasOwnProperty(f)){g=function(){d[c[f]](i)};i.attachEvent("on"+f,g)}}i.attachEvent("onpropertychange",this.readPropertyChange)},giveLayout:function(a){a.style.zoom=1;if(a.currentStyle.position=="static"){a.style.position="relative"}},copyImageBorders:function(b){var c,a;c={borderStyle:true,borderWidth:true,borderColor:true};for(a in c){if(c.hasOwnProperty(a)){b.vml.color.shape.style[a]=b.currentStyle[a]}}},vmlFill:function(e){if(!e.currentStyle){return}else{var d,f,g,b,a,c;d=e.currentStyle}for(b in e.vml){if(e.vml.hasOwnProperty(b)){e.vml[b].shape.style.zIndex=d.zIndex}}e.runtimeStyle.backgroundColor="";e.runtimeStyle.backgroundImage="";f=true;if(d.backgroundImage!="none"||e.isImg){if(!e.isImg){e.vmlBg=d.backgroundImage;e.vmlBg=e.vmlBg.substr(5,e.vmlBg.lastIndexOf('")')-5)}else{e.vmlBg=e.src}g=this;if(!g.imgSize[e.vmlBg]){a=document.createElement("img");g.imgSize[e.vmlBg]=a;a.className=g.ns+"_sizeFinder";a.runtimeStyle.cssText="behavior:none; position:absolute; left:-10000px; top:-10000px; border:none; margin:0; padding:0;";c=function(){this.width=this.offsetWidth;this.height=this.offsetHeight;g.vmlOffsets(e)};a.attachEvent("onload",c);a.src=e.vmlBg;a.removeAttribute("width");a.removeAttribute("height");document.body.insertBefore(a,document.body.firstChild)}e.vml.image.fill.src=e.vmlBg;f=false}e.vml.image.fill.on=!f;e.vml.image.fill.color="none";e.vml.color.shape.style.backgroundColor=d.backgroundColor;e.runtimeStyle.backgroundImage="none";e.runtimeStyle.backgroundColor="transparent"},vmlOffsets:function(d){var h,n,a,e,g,m,f,l,j,i,k;h=d.currentStyle;n={W:d.clientWidth+1,H:d.clientHeight+1,w:this.imgSize[d.vmlBg].width,h:this.imgSize[d.vmlBg].height,L:d.offsetLeft,T:d.offsetTop,bLW:d.clientLeft,bTW:d.clientTop};a=(n.L+n.bLW==1)?1:0;e=function(b,p,q,c,s,u){b.coordsize=c+","+s;b.coordorigin=u+","+u;b.path="m0,0l"+c+",0l"+c+","+s+"l0,"+s+" xe";b.style.width=c+"px";b.style.height=s+"px";b.style.left=p+"px";b.style.top=q+"px"};e(d.vml.color.shape,(n.L+(d.isImg?0:n.bLW)),(n.T+(d.isImg?0:n.bTW)),(n.W-1),(n.H-1),0);e(d.vml.image.shape,(n.L+n.bLW),(n.T+n.bTW),(n.W),(n.H),1);g={X:0,Y:0};if(d.isImg){g.X=parseInt(h.paddingLeft,10)+1;g.Y=parseInt(h.paddingTop,10)+1}else{for(j in g){if(g.hasOwnProperty(j)){this.figurePercentage(g,n,j,h["backgroundPosition"+j])}}}d.vml.image.fill.position=(g.X/n.W)+","+(g.Y/n.H);m=h.backgroundRepeat;f={T:1,R:n.W+a,B:n.H,L:1+a};l={X:{b1:"L",b2:"R",d:"W"},Y:{b1:"T",b2:"B",d:"H"}};if(m!="repeat"||d.isImg){i={T:(g.Y),R:(g.X+n.w),B:(g.Y+n.h),L:(g.X)};if(m.search("repeat-")!=-1){k=m.split("repeat-")[1].toUpperCase();i[l[k].b1]=1;i[l[k].b2]=n[l[k].d]}if(i.B>n.H){i.B=n.H}d.vml.image.shape.style.clip="rect("+i.T+"px "+(i.R+a)+"px "+i.B+"px "+(i.L+a)+"px)"}else{d.vml.image.shape.style.clip="rect("+f.T+"px "+f.R+"px "+f.B+"px "+f.L+"px)"}},figurePercentage:function(d,c,f,a){var b,e;e=true;b=(f=="X");switch(a){case"left":case"top":d[f]=0;break;case"center":d[f]=0.5;break;case"right":case"bottom":d[f]=1;break;default:if(a.search("%")!=-1){d[f]=parseInt(a,10)/100}else{e=false}}d[f]=Math.ceil(e?((c[b?"W":"H"]*d[f])-(c[b?"w":"h"]*d[f])):parseInt(a,10));if(d[f]%2===0){d[f]++}return d[f]},fixPng:function(c){c.style.behavior="none";var g,b,f,a,d;if(c.nodeName=="BODY"||c.nodeName=="TD"||c.nodeName=="TR"){return}c.isImg=false;if(c.nodeName=="IMG"){if(c.src.toLowerCase().search(/\.png$/)!=-1){c.isImg=true;c.style.visibility="hidden"}else{return}}else{if(c.currentStyle.backgroundImage.toLowerCase().search(".png")==-1){return}}g=DD_belatedPNG;c.vml={color:{},image:{}};b={shape:{},fill:{}};for(a in c.vml){if(c.vml.hasOwnProperty(a)){for(d in b){if(b.hasOwnProperty(d)){f=g.ns+":"+d;c.vml[a][d]=document.createElement(f)}}c.vml[a].shape.stroked=false;c.vml[a].shape.appendChild(c.vml[a].fill);c.parentNode.insertBefore(c.vml[a].shape,c)}}c.vml.image.shape.fillcolor="none";c.vml.image.fill.type="tile";c.vml.color.fill.on=false;g.attachHandlers(c);g.giveLayout(c);g.giveLayout(c.offsetParent);c.vmlInitiated=true;g.applyVML(c)}};try{document.execCommand("BackgroundImageCache",false,true)}catch(r){}DD_belatedPNG.createVmlNameSpace();DD_belatedPNG.createVmlStyleSheet();
View
18 libs/generators/_project_generator/templates/default/client/js/vendors/jquery-1.6.1.min.js
@@ -1,18 +0,0 @@
-/*!
- * jQuery JavaScript Library v1.6.1
- * http://jquery.com/
- *
- * Copyright 2011, John Resig
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- *
- * Includes Sizzle.js
- * http://sizzlejs.com/
- * Copyright 2011, The Dojo Foundation
- * Released under the MIT, BSD, and GPL Licenses.
- *
- * Date: Thu May 12 15:04:36 2011 -0400
- */
-(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!cj[a]){var b=f("<"+a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),c.body.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write("<!doctype><html><body></body></html>");b=cl.createElement(a),cl.body.appendChild(b),d=f.css(b,"display"),c.body.removeChild(ck)}cj[a]=d}return cj[a]}function cu(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function ct(){cq=b}function cs(){setTimeout(ct,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h=="string"&&(e[h.toLowerCase()]=a.converters[h]);l=k,k=d[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=e[m]||e["* "+k];if(!n){p=b;for(o in e){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=e[j[1]+" "+k];if(p){o=e[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&f.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function ca(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function b_(a,b,c,d){if(f.isArray(b))f.each(b,function(b,e){c||bF.test(a)?d(a,e):b_(a+"["+(typeof e=="object"||f.isArray(e)?b:"")+"]",e,c,d)});else if(!c&&b!=null&&typeof b=="object")for(var e in b)b_(a+"["+e+"]",b[e],c,d);else d(a,b)}function b$(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bU,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=b$(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=b$(a,c,d,e,"*",g));return l}function bZ(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(f.isFunction(c)){var d=b.toLowerCase().split(bQ),e=0,g=d.length,h,i,j;for(;e<g;e++)h=d[e],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function bD(a,b,c){var d=b==="width"?bx:by,e=b==="width"?a.offsetWidth:a.offsetHeight;if(c==="border")return e;f.each(d,function(){c||(e-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?e+=parseFloat(f.css(a,"margin"+this))||0:e-=parseFloat(f.css(a,"border"+this+"Width"))||0});return e}function bn(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bf,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bm(a){f.nodeName(a,"input")?bl(a):a.getElementsByTagName&&f.grep(a.getElementsByTagName("input"),bl)}function bl(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bk(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bj(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bi(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(var i=0,j=g[h].length;i<j;i++)f.event.add(b,h+(g[h][i].namespace?".":"")+g[h][i].namespace,g[h][i],g[h][i].data)}}}}function bh(a,b){return f.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function X(a,b,c){b=b||0;if(f.isFunction(b))return f.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return f.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=f.grep(a,function(a){return a.nodeType===1});if(S.test(b))return f.filter(b,d,!c);b=f.filter(b,d)}return f.grep(a,function(a,d){return f.inArray(a,b)>=0===c})}function W(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function O(a,b){return(a&&a!=="*"?a+".":"")+b.replace(A,"`").replace(B,"&")}function N(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;i<s.length;i++)g=s[i],g.origType.replace(y,"")===a.type?q.push(g.selector):s.splice(i--,1);e=f(a.target).closest(q,a.currentTarget);for(j=0,k=e.length;j<k;j++){m=e[j];for(i=0;i<s.length;i++){g=s[i];if(m.selector===g.selector&&(!n||n.test(g.namespace))&&!m.elem.disabled){h=m.elem,d=null;if(g.preType==="mouseenter"||g.preType==="mouseleave")a.type=g.preType,d=f(a.relatedTarget).closest(g.selector)[0],d&&f.contains(h,d)&&(d=h);(!d||d!==h)&&p.push({elem:h,handleObj:g,level:m.level})}}}for(j=0,k=p.length;j<k;j++){e=p[j];if(c&&e.level>c)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function L(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function F(){return!0}function E(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(j,"$1-$2").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(g){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function H(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(H,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=d.userAgent,x,y,z,A=Object.prototype.toString,B=Object.prototype.hasOwnProperty,C=Array.prototype.push,D=Array.prototype.slice,E=String.prototype.trim,F=Array.prototype.indexOf,G={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6.1",length:0,size:function(){return this.length},toArray:function(){return D.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?C.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),y.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(D.apply(this,arguments),"slice",D.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:C,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j<k;j++)if((a=arguments[j])!=null)for(c in a){d=i[c],f=a[c];if(i===f)continue;l&&f&&(e.isPlainObject(f)||(g=e.isArray(f)))?(g?(g=!1,h=d&&e.isArray(d)?d:[]):h=d&&e.isPlainObject(d)?d:{},i[c]=e.extend(l,h,f)):f!==b&&(i[c]=f)}return i},e.extend({noConflict:function(b){a.$===e&&(a.$=g),b&&a.jQuery===e&&(a.jQuery=f);return e},isReady:!1,readyWait:1,holdReady:function(a){a?e.readyWait++:e.ready(!0)},ready:function(a){if(a===!0&&!--e.readyWait||a!==!0&&!e.isReady){if(!c.body)return setTimeout(e.ready,1);e.isReady=!0;if(a!==!0&&--e.readyWait>0)return;y.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!y){y=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",z,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",z),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&H()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):G[A.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;if(a.constructor&&!B.call(a,"constructor")&&!B.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a);return c===b||B.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(b,c,d){a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),d=c.documentElement,(!d||!d.nodeName||d.nodeName==="parsererror")&&e.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g<h;)if(c.apply(a[g++],d)===!1)break}else if(i){for(f in a)if(c.call(a[f],f,a[f])===!1)break}else for(;g<h;)if(c.call(a[g],g,a[g++])===!1)break;return a},trim:E?function(a){return a==null?"":E.call(a)}:function(a){return a==null?"":(a+"").replace(k,"").replace(l,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var d=e.type(a);a.length==null||d==="string"||d==="function"||d==="regexp"||e.isWindow(a)?C.call(c,a):e.merge(c,a)}return c},inArray:function(a,b){if(F)return F.call(b,a);for(var c=0,d=b.length;c<d;c++)if(b[c]===a)return c;return-1},merge:function(a,c){var d=a.length,e=0;if(typeof c.length=="number")for(var f=c.length;e<f;e++)a[d++]=c[e];else while(c[e]!==b)a[d++]=c[e++];a.length=d;return a},grep:function(a,b,c){var d=[],e;c=!!c;for(var f=0,g=a.length;f<g;f++)e=!!b(a[f],f),c!==e&&d.push(a[f]);return d},map:function(a,c,d){var f,g,h=[],i=0,j=a.length,k=a instanceof e||j!==b&&typeof j=="number"&&(j>0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i<j;i++)f=c(a[i],i,d),f!=null&&(h[h.length]=f);else for(g in a)f=c(a[g],g,d),f!=null&&(h[h.length]=f);return h.concat.apply([],h)},guid:1,proxy:function(a,c){if(typeof c=="string"){var d=a[c];c=a,a=d}if(!e.isFunction(a))return b;var f=D.call(arguments,2),g=function(){return a.apply(c,f.concat(D.call(arguments)))};g.guid=a.guid=a.guid||g.guid||e.guid++;return g},access:function(a,c,d,f,g,h){var i=a.length;if(typeof c=="object"){for(var j in c)e.access(a,j,c[j],f,g,d);return a}if(d!==b){f=!h&&f&&e.isFunction(d);for(var k=0;k<i;k++)g(a[k],c,f?d.call(a[k],k,g(a[k],c)):d,h);return a}return i?g(a[0],c):b},now:function(){return(new Date).getTime()},uaMatch:function(a){a=a.toLowerCase();var b=s.exec(a)||t.exec(a)||u.exec(a)||a.indexOf("compatible")<0&&v.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}e.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function(d,f){f&&f instanceof e&&!(f instanceof a)&&(f=a(f));return e.fn.init.call(this,d,f,b)},a.fn.init.prototype=a.fn;var b=a(c);return a},browser:{}}),e.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){G["[object "+b+"]"]=b.toLowerCase()}),x=e.uaMatch(w),x.browser&&(e.browser[x.browser]=!0,e.browser.version=x.version),e.browser.webkit&&(e.browser.safari=!0),j.test(" ")&&(k=/^[\s\xA0]+/,l=/[\s\xA0]+$/),h=e(c),c.addEventListener?z=function(){c.removeEventListener("DOMContentLoaded",z,!1),e.ready()}:c.attachEvent&&(z=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",z),e.ready())});return e}(),g="done fail isResolved isRejected promise then always pipe".split(" "),h=[].slice;f.extend({_Deferred:function(){var a=[],b,c,d,e={done:function(){if(!d){var c=arguments,g,h,i,j,k;b&&(k=b,b=0);for(g=0,h=c.length;g<h;g++)i=c[g],j=f.type(i),j==="array"?e.done.apply(e,i):j==="function"&&a.push(i);k&&e.resolveWith(k[0],k[1])}return this},resolveWith:function(e,f){if(!d&&!b&&!c){f=f||[],c=1;try{while(a[0])a.shift().apply(e,f)}finally{b=[e,f],c=0}}return this},resolve:function(){e.resolveWith(this,arguments);return this},isResolved:function(){return!!c||!!b},cancel:function(){d=1,a=[];return this}};return e},Deferred:function(a){var b=f._Deferred(),c=f._Deferred(),d;f.extend(b,{then:function(a,c){b.done(a).fail(c);return this},always:function(){return b.done.apply(b,arguments).fail.apply(this,arguments)},fail:c.done,rejectWith:c.resolveWith,reject:c.resolve,isRejected:c.isResolved,pipe:function(a,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[c,"reject"]},function(a,c){var e=c[0],g=c[1],h;f.isFunction(e)?b[a](function(){h=e.apply(this,arguments),h&&f.isFunction(h.promise)?h.promise().then(d.resolve,d.reject):d[g](h)}):b[a](d[g])})}).promise()},promise:function(a){if(a==null){if(d)return d;d=a={}}var c=g.length;while(c--)a[g[c]]=b[g[c]];return a}}),b.done(c.cancel).fail(b.cancel),delete b.cancel,a&&a.call(b,b);return b},when:function(a){function i(a){return function(c){b[a]=arguments.length>1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c<d;c++)b[c]&&f.isFunction(b[c].promise)?b[c].promise().then(i(c),g.reject):--e;e||g.resolveWith(g,b)}else g!==a&&g.resolveWith(g,d?[a]:[]);return g.promise()}}),f.support=function(){var a=c.createElement("div"),b=c.documentElement,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;a.setAttribute("className","t"),a.innerHTML=" <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};f=c.createElement("select"),g=f.appendChild(c.createElement("option")),h=a.getElementsByTagName("input")[0],j={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:h.value==="on",optSelected:g.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},h.checked=!0,j.noCloneChecked=h.cloneNode(!0).checked,f.disabled=!0,j.optDisabled=!g.disabled;try{delete a.test}catch(s){j.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function b(){j.noCloneEvent=!1,a.detachEvent("onclick",b)}),a.cloneNode(!0).fireEvent("onclick")),h=c.createElement("input"),h.value="t",h.setAttribute("type","radio"),j.radioValue=h.value==="t",h.setAttribute("checked","checked"),a.appendChild(h),k=c.createDocumentFragment(),k.appendChild(a.firstChild),j.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",l=c.createElement("body"),m={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"};for(q in m)l.style[q]=m[q];l.appendChild(a),b.insertBefore(l,b.firstChild),j.appendChecked=h.checked,j.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,j.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="<div style='width:4px;'></div>",j.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>",n=a.getElementsByTagName("td"),r=n[0].offsetHeight===0,n[0].style.display="",n[1].style.display="none",j.reliableHiddenOffsets=r&&n[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(i=c.createElement("div"),i.style.width="0",i.style.marginRight="0",a.appendChild(i),j.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(i,null)||{marginRight:0}).marginRight,10)||0)===0),l.innerHTML="",b.removeChild(l);if(a.attachEvent)for(q in{submit:1,change:1,focusin:1})p="on"+q,r=p in a,r||(a.setAttribute(p,"return;"),r=typeof a[p]=="function"),j[q+"Bubbles"]=r;return j}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([a-z])([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g=f.expando,h=typeof c=="string",i,j=a.nodeType,k=j?f.cache:a,l=j?a[f.expando]:a[f.expando]&&f.expando;if((!l||e&&l&&!k[l][g])&&h&&d===b)return;l||(j?a[f.expando]=l=++f.uuid:l=f.expando),k[l]||(k[l]={},j||(k[l].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?k[l][g]=f.extend(k[l][g],c):k[l]=f.extend(k[l],c);i=k[l],e&&(i[g]||(i[g]={}),i=i[g]),d!==b&&(i[f.camelCase(c)]=d);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[f.camelCase(c)]:i}},removeData:function(b,c,d){if(!!f.acceptData(b)){var e=f.expando,g=b.nodeType,h=g?f.cache:b,i=g?b[f.expando]:f.expando;if(!h[i])return;if(c){var j=d?h[i][e]:h[i];if(j){delete j[c];if(!l(j))return}}if(d){delete h[i][e];if(!l(h[i]))return}var k=h[i][e];f.support.deleteExpando||h!=a?delete h[i]:h[i]=null,k?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=k):g&&(f.support.deleteExpando?delete b[f.expando]:b.removeAttribute?b.removeAttribute(f.expando):b[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h<i;h++)g=e[h].name,g.indexOf("data-")===0&&(g=f.camelCase(g.substring(5)),k(this[0],g,d[g]))}}return d}if(typeof a=="object")return this.each(function(){f.data(this,a)});var j=a.split(".");j[1]=j[1]?"."+j[1]:"";if(c===b){d=this.triggerHandler("getData"+j[1]+"!",[j[0]]),d===b&&this.length&&(d=f.data(this[0],a),d=k(this[0],a,d));return d===b&&j[1]?this.data(j[0]):d}return this.each(function(){var b=f(this),d=[j[0],c];b.triggerHandler("setData"+j[1]+"!",d),f.data(this,a,c),b.triggerHandler("changeData"+j[1]+"!",d)})},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,c){a&&(c=(c||"fx")+"mark",f.data(a,c,(f.data(a,c,b,!0)||0)+1,!0))},_unmark:function(a,c,d){a!==!0&&(d=c,c=a,a=!1);if(c){d=d||"fx";var e=d+"mark",g=a?0:(f.data(c,e,b,!0)||1)-1;g?f.data(c,e,g,!0):(f.removeData(c,e,!0),m(c,d,"mark"))}},queue:function(a,c,d){if(a){c=(c||"fx")+"queue";var e=f.data(a,c,b,!0);d&&(!e||f.isArray(d)?e=f.data(a,c,f.makeArray(d),!0):e.push(d));return e||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e;d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),d.call(a,function(){f.dequeue(a,b)})),c.length||(f.removeData(a,b+"queue",!0),m(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){typeof a!="string"&&(c=a,a="fx");if(c===b)return f.queue(this[0],a);return this.each(function(){var b=f.queue(this,a,c);a==="fx"&&b[0]!=="inprogress"&&f.dequeue(this,a)})},dequeue:function(a){return this.each(function(){f.dequeue(this,a)})},delay:function(a,b){a=f.fx?f.fx.speeds[a]||a:a,b=b||"fx";return this.queue(b,function(){var c=this;setTimeout(function(){f.dequeue(c,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){function m(){--h||d.resolveWith(e,[e])}typeof a!="string"&&(c=a,a=b),a=a||"fx";var d=f.Deferred(),e=this,g=e.length,h=1,i=a+"defer",j=a+"queue",k=a+"mark",l;while(g--)if(l=f.data(e[g],i,b,!0)||(f.data(e[g],j,b,!0)||f.data(e[g],k,b,!0))&&f.data(e[g],i,f._Deferred(),!0))h++,l.done(m);m();return d.promise()}});var n=/[\n\t\r]/g,o=/\s+/,p=/\r/g,q=/^(?:button|input)$/i,r=/^(?:button|input|object|select|textarea)$/i,s=/^a(?:rea)?$/i,t=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,u=/\:/,v,w;f.fn.extend({attr:function(a,b){return f.access(this,a,b,!0,f.attr)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,a,b,!0,f.prop)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.addClass(a.call(this,b,c.attr("class")||""))});if(a&&typeof a=="string"){var b=(a||"").split(o);for(var c=0,d=this.length;c<d;c++){var e=this[c];if(e.nodeType===1)if(!e.className)e.className=a;else{var g=" "+e.className+" ",h=e.className;for(var i=0,j=b.length;i<j;i++)g.indexOf(" "+b[i]+" ")<0&&(h+=" "+b[i]);e.className=f.trim(h)}}}return this},removeClass:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.removeClass(a.call(this,b,c.attr("class")))});if(a&&typeof a=="string"||a===b){var c=(a||"").split(o);for(var d=0,e=this.length;d<e;d++){var g=this[d];if(g.nodeType===1&&g.className)if(a){var h=(" "+g.className+" ").replace(n," ");for(var i=0,j=c.length;i<j;i++)h=h.replace(" "+c[i]+" "," ");g.className=f.trim(h)}else g.className=""}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";if(f.isFunction(a))return this.each(function(c){var d=f(this);d.toggleClass(a.call(this,c,d.attr("class"),b),b)});return this.each(function(){if(c==="string"){var e,g=0,h=f(this),i=b,j=a.split(o);while(e=j[g++])i=d?i:!h.hasClass(e),h[i?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&f._data(this,"__className__",this.className),this.className=this.className||a===!1?"":f._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ";for(var c=0,d=this.length;c<d;c++)if((" "+this[c].className+" ").replace(n," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;return(e.value||"").replace(p,"")}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,