From 0cbf320a51c9b33e8c678c3085c9effeaebffce2 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 6 Aug 2012 12:18:46 +0200 Subject: [PATCH] Remove Broke.js It's now in the Wiki: https://github.com/addyosmani/todomvc/wiki/Other-implementations --- index.html | 5 +- .../apple-touch-icon-114x114-precomposed.png | Bin 1032 -> 0 bytes .../apple-touch-icon-57x57-precomposed.png | Bin 640 -> 0 bytes .../apple-touch-icon-72x72-precomposed.png | Bin 747 -> 0 bytes .../broke/apple-touch-icon-precomposed.png | Bin 640 -> 0 bytes .../broke/apple-touch-icon.png | Bin 640 -> 0 bytes .../broke/css/application.css | 182 - labs/architecture-examples/broke/favicon.ico | Bin 1150 -> 0 bytes .../broke/images/delete.png | Bin 1334 -> 0 bytes .../broke/images/pencil.png | Bin 1221 -> 0 bytes labs/architecture-examples/broke/index.html | 46 - .../broke/libs/broke-client-0.2b.min.js | 4891 ----------------- .../broke/libs/gettext.min.js | 54 - .../broke/libs/jquery-1.6.4.min.js | 4 - .../broke/libs/pyjammin.min.js | 84 - .../broke/project/models.js | 13 - .../broke/project/my-blog.js | 15 - .../broke/project/settings.js | 28 - .../broke/project/templates.js | 25 - .../broke/project/urls.js | 14 - .../broke/project/views.js | 110 - readme.md | 3 +- 22 files changed, 2 insertions(+), 5472 deletions(-) delete mode 100644 labs/architecture-examples/broke/apple-touch-icon-114x114-precomposed.png delete mode 100644 labs/architecture-examples/broke/apple-touch-icon-57x57-precomposed.png delete mode 100644 labs/architecture-examples/broke/apple-touch-icon-72x72-precomposed.png delete mode 100644 labs/architecture-examples/broke/apple-touch-icon-precomposed.png delete mode 100644 labs/architecture-examples/broke/apple-touch-icon.png delete mode 100644 labs/architecture-examples/broke/css/application.css delete mode 100644 labs/architecture-examples/broke/favicon.ico delete mode 100644 labs/architecture-examples/broke/images/delete.png delete mode 100644 labs/architecture-examples/broke/images/pencil.png delete mode 100644 labs/architecture-examples/broke/index.html delete mode 100644 labs/architecture-examples/broke/libs/broke-client-0.2b.min.js delete mode 100644 labs/architecture-examples/broke/libs/gettext.min.js delete mode 100644 labs/architecture-examples/broke/libs/jquery-1.6.4.min.js delete mode 100644 labs/architecture-examples/broke/libs/pyjammin.min.js delete mode 100644 labs/architecture-examples/broke/project/models.js delete mode 100644 labs/architecture-examples/broke/project/my-blog.js delete mode 100644 labs/architecture-examples/broke/project/settings.js delete mode 100644 labs/architecture-examples/broke/project/templates.js delete mode 100644 labs/architecture-examples/broke/project/urls.js delete mode 100644 labs/architecture-examples/broke/project/views.js diff --git a/index.html b/index.html index 14bf1a5127..223ced83ad 100644 --- a/index.html +++ b/index.html @@ -211,9 +211,6 @@

Labs

  • rAppid.js
  • -
  • - Broke.js -
  • Funnyface.js
  • @@ -265,4 +262,4 @@

    Labs

    - \ No newline at end of file + diff --git a/labs/architecture-examples/broke/apple-touch-icon-114x114-precomposed.png b/labs/architecture-examples/broke/apple-touch-icon-114x114-precomposed.png deleted file mode 100644 index de2d59f92cae78ec291461ca1d5de47763d391b7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1032 zcmeAS@N?(olHy`uVBq!ia0vp^MIg+<3?z3jm-+*#0|7oEuAb@nZs`RN(~N;6gyEN- z3+F;afLxc<-216Uktu06Q;aSr89OFso=Gq|7H4E1o0=0FZWo=jH`;JpgkgDvpKW;D zx=@4W5U0gK2G&90GXjhz`Wf5!1$w)=1UXs7S!-)r+QeFEhMQ~Xn3@KeshgM>`I@NP z8)~ZP>Z<7JDQT!GsbfcqsNymzDsrkSdow=8F)%PQd%8G=WZZi@)BpS;1A%sR+c&*$ z4rRxAiiikxNM-MQ%e(*o_NY_xYdcEPPHnom#8!Cz2MgoBy-r(yG4_A)fT0urIah|c zuUhkOuhAxsY;`r}nO(uPeWyexdUdQ>$9N;aYLmbs!)gXI5s5h0nCO>w@nnXFXq9+=A&U?x1Ul;f~EnA@YTF=q#8R6z( zD`#x%%elB?)o#;r3+to%Jp*)Cy?&Oq=h2(mwjF!c=^(^1Z;VTkQ^F*Baf8yB(H2UdM6w4Aaf*n7iNo zPICtAP5U*^E9RQrf=XGZ$LD$L-!f0So}Te%WBp!VjlJg3{JyXvXji1P(VQC(;_NIr zt2e7&(@FTZXvWhq3W!gXN{7{s|D6G&dN?~ zQ^@(Boy%*oFoPT!igj|>RqhB{O7*jqws{Tulo4VTdKX25diY4w6@I{R}PqLv#F{+q{jceJoAA1B_ig4IEwcZR~U{taMDxH4Kf^_4Jjr zG!->9)HGCev{aQfR29`#l~9o~Di>My>B*mV3=E9bo-U3d9>?EKJJ{D`Akg;w+T=Bj zS9(=C8bnx9Y~JPG`@eRZYtok6WfR^^v=p4AU-RelbcXL+nWcA5v?(!`<3v{M z)9bAbYp(6(EKE3I=pCPCK6!$d=Gop$XDW*AihUGqs#TWW*%m6`v(o;>lBu6<4L>%E zzTEIdhCSUW`PoC2ONC6?`P+`3W1V)zwXJ*ifv|voy~~!K{&L{5z`gWL_hvOIMWv%= z4`rt=QM>GXzWjylGTWnJCUHeua-#oE3f#S9d#mfSz30*bAHSXJx9c#|C(YUWU#((& zqBC2e_I&D@^?tDhr_-(+ee}9;?u0mQf4@z?yI!p{?KfIZFjlG{O zyMNt1d)LlDH}j;EcQ@aEUMZaW=-O8QnMY>deQ#L&DoQ2j@eA`;{s~9&mYO{|TDU#& pw)vHfi|;$f=GO;F|2+Rh|Lbff^@O$?_P`{?;OXk;vd$@?2>^oK4mtn; diff --git a/labs/architecture-examples/broke/apple-touch-icon-72x72-precomposed.png b/labs/architecture-examples/broke/apple-touch-icon-72x72-precomposed.png deleted file mode 100644 index b20e78ef3920a3f46e552fe179c5d59dabd675c6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 747 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAk#fdHQn*N17wXy|^Lv0Hip4CT9| z=7yza-Apk~PENU;WaONb?HHeaBF@l0Hf3*=fo){M)^Pom;U{jZOSb)V+<>-3-<3_0=2=)U0&Xl(e;tv{g-Y)bzDg zl{A1zO977@wzny-%ui1ddb?@mU zITMj6r-e%t6a_iYR)zihzkilUMrQZt1si6t{%lw*b9|q~kI0t?*lsyUzo>6eS;xGJ zS*Od?fywLWqa;fWrp7rNOEgz7a(p-|o(}GK~_(^P;m#IBg6Po2TkYR=e#L*=_qH=J_q2Uo|P) z!i!(9s;=7c{EhbS&({~W3U8h9w(8u;o9?+um%Z569$K!b8vA*}v99lPB7T;Z`ECtq zn(#2{j(bdUqTKgGyg+`v0xHV0x`<;{g^T^Bkol>QuU8^e%ok|-*F25^mV)}G- zi}ZZ%}Z`jN>C*MDPKi=H@v=D=sacAx84d*Ys zWpmqHE%54nyU^he#gChq)i$T_9Lio4=XAV@c}t{$*c>lb=W@@3bL(-Y=(-m@Db7Ssln68nS`TlMqoB5}otKT`zx%0i)Pv4^LrGC&| wo3_Lgm3HZCH?BQgY*hVQ^sa++M(hRo#B*|C9>pOFz|_m&>FVdQ&MBb@0NJQ0PXGV_ diff --git a/labs/architecture-examples/broke/apple-touch-icon-precomposed.png b/labs/architecture-examples/broke/apple-touch-icon-precomposed.png deleted file mode 100644 index 6d2fc3969d2a377bc1b0e345e20ef5c15bd21a2f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 640 zcmeAS@N?(olHy`uVBq!ia0vp^mLSZ*3?z3SE8Y&I4g~mwxIRoXMnezMjNH--+|u*G zWWl{uBiGct8!5&vDY;%L*%y6@I{R}PqLv#F{+q{jceJoAA1B_ig4IEwcZR~U{taMDxH4Kf^_4Jjr zG!->9)HGCev{aQfR29`#l~9o~Di>My>B*mV3=E9bo-U3d9>?EKJJ{D`Akg;w+T=Bj zS9(=C8bnx9Y~JPG`@eRZYtok6WfR^^v=p4AU-RelbcXL+nWcA5v?(!`<3v{M z)9bAbYp(6(EKE3I=pCPCK6!$d=Gop$XDW*AihUGqs#TWW*%m6`v(o;>lBu6<4L>%E zzTEIdhCSUW`PoC2ONC6?`P+`3W1V)zwXJ*ifv|voy~~!K{&L{5z`gWL_hvOIMWv%= z4`rt=QM>GXzWjylGTWnJCUHeua-#oE3f#S9d#mfSz30*bAHSXJx9c#|C(YUWU#((& zqBC2e_I&D@^?tDhr_-(+ee}9;?u0mQf4@z?yI!p{?KfIZFjlG{O zyMNt1d)LlDH}j;EcQ@aEUMZaW=-O8QnMY>deQ#L&DoQ2j@eA`;{s~9&mYO{|TDU#& pw)vHfi|;$f=GO;F|2+Rh|Lbff^@O$?_P`{?;OXk;vd$@?2>^oK4mtn; diff --git a/labs/architecture-examples/broke/apple-touch-icon.png b/labs/architecture-examples/broke/apple-touch-icon.png deleted file mode 100644 index 6d2fc3969d2a377bc1b0e345e20ef5c15bd21a2f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 640 zcmeAS@N?(olHy`uVBq!ia0vp^mLSZ*3?z3SE8Y&I4g~mwxIRoXMnezMjNH--+|u*G zWWl{uBiGct8!5&vDY;%L*%y6@I{R}PqLv#F{+q{jceJoAA1B_ig4IEwcZR~U{taMDxH4Kf^_4Jjr zG!->9)HGCev{aQfR29`#l~9o~Di>My>B*mV3=E9bo-U3d9>?EKJJ{D`Akg;w+T=Bj zS9(=C8bnx9Y~JPG`@eRZYtok6WfR^^v=p4AU-RelbcXL+nWcA5v?(!`<3v{M z)9bAbYp(6(EKE3I=pCPCK6!$d=Gop$XDW*AihUGqs#TWW*%m6`v(o;>lBu6<4L>%E zzTEIdhCSUW`PoC2ONC6?`P+`3W1V)zwXJ*ifv|voy~~!K{&L{5z`gWL_hvOIMWv%= z4`rt=QM>GXzWjylGTWnJCUHeua-#oE3f#S9d#mfSz30*bAHSXJx9c#|C(YUWU#((& zqBC2e_I&D@^?tDhr_-(+ee}9;?u0mQf4@z?yI!p{?KfIZFjlG{O zyMNt1d)LlDH}j;EcQ@aEUMZaW=-O8QnMY>deQ#L&DoQ2j@eA`;{s~9&mYO{|TDU#& pw)vHfi|;$f=GO;F|2+Rh|Lbff^@O$?_P`{?;OXk;vd$@?2>^oK4mtn; diff --git a/labs/architecture-examples/broke/css/application.css b/labs/architecture-examples/broke/css/application.css deleted file mode 100644 index 34992fe9e2..0000000000 --- a/labs/architecture-examples/broke/css/application.css +++ /dev/null @@ -1,182 +0,0 @@ -html, body { - margin: 0; - padding: 0; -} - -body { - font-family: "Helvetica Neue", helvetica, arial, sans-serif; - font-size: 14px; - line-height: 1.4em; - background: #eeeeee; - color: #333333; -} - -#views { - width: 520px; - margin: 0 auto 40px auto; - background: white; - - -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0; - -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0; - -o-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0; - box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0; - - -moz-border-radius: 0 0 5px 5px; - -o-border-radius: 0 0 5px 5px; - -webkit-border-radius: 0 0 5px 5px; - border-radius: 0 0 5px 5px; -} - -#tasks { - padding: 20px; -} - -#tasks h1 { - font-size: 36px; - font-weight: bold; - text-align: center; - padding: 0 0 10px 0; -} - -#tasks input[type="text"] { - width: 466px; - font-size: 24px; - font-family: inherit; - line-height: 1.4em; - border: 0; - outline: none; - padding: 6px; - border: 1px solid #999999; - - -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset; - -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset; - -o-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset; - box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset; -} - -#tasks input::-webkit-input-placeholder { - font-style: italic; -} - -#tasks .items { - margin: 10px 0; - list-style: none; - padding: 0; -} - -#tasks .item { - padding: 15px 20px 15px 0; - position: relative; - font-size: 24px; - border-bottom: 1px solid #cccccc; -} - -#tasks .item.done span { - color: #777777; - text-decoration: line-through; -} - -#tasks .item .destroy { - position: absolute; - right: 10px; - top: 16px; - display: none; - cursor: pointer; - width: 20px; - height: 20px; - background: url(../images/delete.png) no-repeat center center; -} - -#tasks .item .edit { - position: absolute; - right: 36px; - top: 16px; - display: none; - cursor: pointer; - width: 20px; - height: 20px; - background: url(../images/pencil.png) no-repeat center center; -} - -#tasks .item:hover .destroy, -#tasks .item:hover .edit { - display: block; -} - -#tasks .item.editing .edit { display: block; } -#tasks .item.editing .view { display: none; } - -#tasks footer { - display: block; - margin: 20px -20px -20px -20px; - overflow: hidden; - - color: #555555; - background: #f4fce8; - border-top: 1px solid #ededed; - padding: 0 20px; - line-height: 36px; - - -moz-border-radius: 0 0 5px 5px; - -o-border-radius: 0 0 5px 5px; - -webkit-border-radius: 0 0 5px 5px; - border-radius: 0 0 5px 5px; -} - -#tasks .clear { - display: block; - float: right; - line-height: 20px; - text-decoration: none; - - background: rgba(0, 0, 0, 0.1); - color: #555555; - font-size: 11px; - margin-top: 8px; - margin-bottom:8px; - padding: 0 10px 1px; - - -moz-border-radius: 12px; - -webkit-border-radius: 12px; - -o-border-radius: 12px; - border-radius: 12px; - - -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0; - -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0; - -o-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0; - box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0 0; - - cursor: pointer; -} - -#tasks .clear:hover, #tasks .clear:focus { - background: rgba(0, 0, 0, 0.15); - -moz-box-shadow: rgba(0, 0, 0, 0.3) 0 -1px 0 0; - -webkit-box-shadow: rgba(0, 0, 0, 0.3) 0 -1px 0 0; - -o-box-shadow: rgba(0, 0, 0, 0.3) 0 -1px 0 0; - box-shadow: rgba(0, 0, 0, 0.3) 0 -1px 0 0; -} - -#tasks .clear:active { - position: relative; - top: 1px; -} - -#tasks .count span { - font-weight: bold; -} - - -#credits { - width: 520px; - margin: 30px auto; - color: - #999; - text-shadow: - rgba(255, 255, 255, .8) 0 1px 0; - text-align: center; -} - -#credits a { - color: #888; -} diff --git a/labs/architecture-examples/broke/favicon.ico b/labs/architecture-examples/broke/favicon.ico deleted file mode 100644 index 4ec0d298859a6e33a6cc40f7a502354b8cad5f76..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1150 zcmZvc&rcIU6vv0?T~3}Vg?4v#yIp9zU1&k*FC;0yN&pE-r71xP79vXcVT>0+io~c1 z@uXK{B+(d6OeFpaN@9YEe?#HwsR-_La3ytienMto~)nRwQ- ztEU+|%NSFI377ELelaj6V$~l2tkU-O_ua*{^@FsA{g}@8q9dxKtviRl!Uob8+Ta!EAg$QvH?ga$D;u=7jC-I3O|)O%LUjBohDWow zICCGdrSIq+zm4V)7dd%ttzd{992)p}!V915J%{L}2T0!ff%9UY*uq!DZ@fotY!u;; zX657PiH$^CemQGdZh)@35gRKaxwM1C!WSeLx6xjBh3x1cW+(a)Yd0au_8EwEcrMo? z6gJQ~@d&A#Hk+9Lgv9)3Bo@CRI{6%#ksRiyhLGurTeTsU&cH?9ej|$5l_!YLeL(Em z8!>K)-xsXdBQ^KV${{lK5~)lcopIBu6|wgHNl^7h_yW!FH3p#g6d1kJ)*Ym0pP{F_ z6SAg53mD*f@Z|i&p43m&UQtACgmJkJTBrpbb03kpyo^>;fh5%*$L-vy=EPDDIQ`?? zBaNIlpe_Fx10z}ZRJ-Ptai@QXr(T?%DZH+X6CdcvAYh0yD}QTF8q!wwuhYl$ZW!U< z0rjZWr<9K>?&f$+vH!h44o_ogZ{NMVvQ|u{(z`B~x9oCBWtx+ZVwGB&AG#SUpJ8nK U6k~U4Y^(l{aMn(ow8Rkm2iEifo&W#< diff --git a/labs/architecture-examples/broke/images/delete.png b/labs/architecture-examples/broke/images/delete.png deleted file mode 100644 index de00a243fe6669ae962dae1df3d97eb9899b3324..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1334 zcmbVMZA{!`94{CQAueGuKWL10#Tk~twY_rJyM_aM?HxPA!FjwY2JKx7SC6(wTeySi z#Hq-JEZJZV#)f9hC4%5EOUy*4k>kZkMrPEAB8%+97G*)BMlhT6DRAfqvJW=7@m$ z1x;yGgP4v~kyZ;sSZJ3E z!*RPa7qgLsnYH1J6?2mbj;*jxnjuKs>2#79K)NuRwd67cZKLfLvxO$?39LufbWRQm z3A-Y&yMd+eh@}`+;B-YTQ!kt#9+iYfmJQsMrj^+PP#!%o4YP80GS|uR@{by`9 z8y_4tM@Nvsyr^I>Ud`@Wg`lL6ho#G6-<|2E3)v@jOx4M~-8-L}NXLgN@XKf8*s#BE zH5or$e)-Yoj-B>)#KXkzDYeAUQ^62X6o0p^f;r#W&V6;*)a+;+op>JZU#+269y`x^KZ?I}DPt~OVm}O2 z&$L^5g2NppeLW95n~t8H?%0z&zJ2#=OTDvsxa*neFP}`GT0Gf3IS0L&5%_7;*E`@| z%qK4VaHufw#o_PqvFS4(geM2D4i@-I!rR}eSo-TYTXN6b%@e*y_T;;+!j+1CRf@zd&j!yDt*+ImjhW|!_;KF95DijQQ)l2g8+R(h6e=96w(11T3w582eNKgh|6 uSC%hcaUZ=kZM9}}4#yYX>%39jngqT4dQo@Vq1I!@pUmSbW=EXQ9{2}=tK+o* diff --git a/labs/architecture-examples/broke/images/pencil.png b/labs/architecture-examples/broke/images/pencil.png deleted file mode 100644 index f8de0551a763641fe2d0299e3c428c4e12ed1648..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1221 zcmbVMTWB0r7#;~26ReWfvTdwkI#n7aJ9B0>GqW@9+U{JE-87qq&C+aVwoX$!_!^^ud9d zbNj#V`~Uy^|2#c7(7Ud+y_Fz{b-Aooz~lPpz3o=~-E-mjVLWU`dI=4AWmGW&NMtN; z6p}f|7=s09ShG`Kz!X6=S$466O8I`-^c>oVZ0M@vV>Cgec2s@CoPdZNg=4mxrhYs9 z5k=Zoni}TwAn&Vi+|JGgaADr(0HnauY@%Bf#V(QqEMNe~uw0xKd1|0Y>UT0U1_JuzHdQK;w12fz7!gGF%fjbZx9#$0|3) z%4z@&8Dp?BOjH{GDV4?+uD@uyTKIUe+B(q1{Sx5D zIKOMdF5Fbtb6TcY{qFTk3$3?gwtP1Api`@LJkdN@=-An^m=UDQm#_By(bC!c{!7m` z9rdYLh1oh#>)3h!&*IV#uO72!$~TtY;ZL7g6n;8rywV4@zx~zH#&&o9^VZar%02X# z+>s}1qaQxH;l~598@Ku9#8JYhF2X~c3 diff --git a/labs/architecture-examples/broke/index.html b/labs/architecture-examples/broke/index.html deleted file mode 100644 index 796692b23b..0000000000 --- a/labs/architecture-examples/broke/index.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - Broke.js - - - -
    -
    -

    todos

    - -
    - -
    - -
    - - -
    -
    - -
    -

    Created by Davide Callegari

    -

    Part of TodoMVC

    -
    - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/labs/architecture-examples/broke/libs/broke-client-0.2b.min.js b/labs/architecture-examples/broke/libs/broke-client-0.2b.min.js deleted file mode 100644 index 73504194a4..0000000000 --- a/labs/architecture-examples/broke/libs/broke-client-0.2b.min.js +++ /dev/null @@ -1,4891 +0,0 @@ -/* - * Broke-client - Davide Callegari - http://www.brokenseal.it/ - * - * Inspired by the Django Web Framework - http://www.djangoproject.com/ - * A lot of inspirement/copy from other Javascript Libraries like: - * - jQuery - http://jquery.com/ - * - JavascriptMVC - http://javascriptmvc.com/ - * - * Licensed under MIT. - * - */ -var broke= {}; - -;(function(__global__, undefined){ - var - extend= function() { - var - name, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false, - options, - src, - copy - ; - - if(arguments.length > 2) { - broke.extend.apply(broke, arguments.slice(1)); - } - // copy reference to target object - // Handle a deep copy situation - if ( typeof target === "boolean" ) { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } - // Handle case when target is a string or something (possible in deep copy) - if ( typeof target !== "object" && !(target instanceof Function)) { - target = {}; - } - // extend broke itself if only one argument is passed - if ( length == i ) { - target = this; - --i; - } - while(i < length) { - // Only deal with non-null/undefined values - if ( (options = arguments[ i ]) !== null ) { - // Extend the base object - for ( name in options ) { - if(options.hasOwnProperty(name)) { - src = target[ name ]; - copy = options[ name ]; - - // Prevent never-ending loop - if ( target === copy ) { - continue; - } - // Recurse if we're merging object values - if ( deep && copy && typeof copy === "object" && !copy.nodeType ) { - target[ name ]= broke.extend( deep, src || ( copy.length !== null ? [ ] : { } ), copy ); - } - - // Don't bring in undefined values - else if ( copy !== undefined ) { - target[ name ] = copy; - } - } - } - } - - i++; - } - // Return the modified object - return target; - } - ,bindEvents= function(){ - var - callback - ,oldHash - ,settings= broke.conf.settings - ; - - /******************************** EVENTS BINDING ********************************/ - // elements binding - if(settings.EVENT_TRIGGERING_METHOD == 'elements'){ - // --------- on elements --------- - broke.bindEvents(); - - // hash change binding - } else if(settings.EVENT_TRIGGERING_METHOD == 'hashchange'){ - - // if it does not exist, let's create it - if(!('onhashchange' in window)){ - oldHash= location.hash; - - setInterval(function(){ - if(location.hash !== oldHash) { - oldHash= location.hash; - - broke.DOM.e.trigger(window, 'hashchange'); - } - }, settings.HASHCHANGE_INTERVAL); - } - - // bind on hash change - window.onhashchange= function(e){ - broke.events.request({ - event: e - ,url: location.hash.split('#')[1] - }); - }; - } - } - ,initProject= function(){ - var - settings= broke.conf.settings - ; - - // init installed apps' models - settings.INSTALLED_APPS= builtins.map(settings.INSTALLED_APPS, function(){ - var - app= this - ; - - if(builtins.typeOf(app) == "string") { - app= builtins.getattr(this); - } - - if(!app) { - return null; - } - - // init app's models - builtins.forEach(app.models, function(){ - var - tableName - ,defaultDbEngine - ; - - if(this.isUsable === false) { - return; - } - - defaultDbEngine= builtins.getattr(broke.conf.settings.DATABASES['default'].ENGINE); - defaultDbEngine.initTableForModel(this); - - // is this still useful? - //if(settings.ENABLE_FETCH_REMOTE_DATA && this.autoInit) { - // init the local storage data - //broke.initStorage(this); - //} - - broke.db.models.addContentType(this.appLabel, this.__name__.toLowerCase(), this); - }); - - return app; - }); - - return settings; - } - ; - - extend(broke, { - /**************************** VERSION ********************************/ - VERSION: "0.2b" - - /************************ SETTINGS OBJECT ****************************/ - ,BROKE_SETTINGS_OBJECT: null // it points to the registered project's settings - // equivalent of Django's DJANGO_SETTINGS_MODULE - - /****************************** INIT *********************************/ - ,init: function(settingsObject, callback){ - var - settings= broke.conf.settings - ,currentUrl= location.hash.split('#')[1] || '' - ; - - if(broke.events.isReady()) { - // already initialized - broke.log('Broke has already been initialized! Fail silently...'); - return; - } - - if(!broke.BROKE_SETTINGS_OBJECT && !settingsObject) { - // no settings object defined, fail out loud - broke.log(gettext.gettext('Settings object not defined!')); - - return; - } else if(!broke.BROKE_SETTINGS_OBJECT && settingsObject) { - - if(builtins.typeOf(settingsObject) == "string") { - settingsObject= builtins.getattr(settingsObject); - } - - extend(settings, settingsObject); - } else { - extend(settings, builtins.getattr(broke.BROKE_SETTINGS_OBJECT)); - } - - // init project - initProject(); - - //if(settings.USE_I18N) { - // determine the language - //_setLanguage(); - - // get language files - //_getLanguageFiles(); - //} - - // bind events - bindEvents(); - - if(builtins.typeOf(callback) == "function") { - callback(); - } - - // cache init - //broke.core.cache.cache= broke.core.cache.getCache(settings.CACHE_BACKEND); - - // on broke init, request the current hash value, even if it's an empty string - broke.events.request(currentUrl); - - broke.events.ready(); - } - ,extend: extend - ,log: function(debugString, doNotAppendDate){ - if(broke.conf.settings.DEBUG && 'console' in window) { - if(!doNotAppendDate) { - var now= new Date(); - now= builtins.interpolate('%s:%s:%s:%s', [now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds()]); - debugString= builtins.interpolate('[%s] %s', [now, debugString]); - } - - console.debug(debugString); - } - } - ,bindEvents: function(context, applyToContext){ - var - settings= broke.conf.settings - ,callback= function(e){ - var - tag= this.tagName.toLowerCase() - ,urlChangingElement= settings.URL_CHANGING_ELEMENTS[tag] - ,preventDefault= urlChangingElement.preventDefault !== undefined ? urlChangingElement.preventDefault : settings.PREVENT_DEFAULT - ,urlAttribute= urlChangingElement.urlAttribute - ,url= broke.DOM.attr(this, urlAttribute) - ,type= e.target.tagName.toLowerCase() == "form" ? 'POST' : 'GET' - ; - - if(url !== undefined && url.indexOf('#') >= 0) { - if(preventDefault) { - e.preventDefault(); - } - - broke.events.request({ - event: e, - url: url.split('#')[1], - completeUrl: url, - type: type - }); - } - } - ; - context= context || document; - - // collect all the url changing elements - builtins.forEach(settings.URL_CHANGING_ELEMENTS, function(key){ - var - domQueryResult - ; - - if(applyToContext === true) { - domQueryResult= context; - } else { - domQueryResult= broke.DOM.q(key, context); - } - - // bind only support, need to make delegate available and change settings - broke.DOM.e.addListener(domQueryResult, this.events.join(','), callback); - }); - } - ,DOM: {} - ,conf: {} - ,core: {} - ,db: {} - }); -})(this);;(function(__global__, undefined){ - var - querySelectorCache= {} - ; - - broke.extend(broke.DOM, { - querySelector: function(query, context){ - var - queryResult - ; - - context= context || document; - queryResult= jQuery(query, jQuery(context)); - - return queryResult; - } - ,clearCache: function(){ - querySelectorCache= {}; - - return; - } - ,val: function(object, value){ - - if(value !== undefined) { - jQuery(object).val(value); - - return object; - } - - return jQuery(object).val(); - } - ,attr: function(object, attributeName, value){ - if(value !== undefined) { - jQuery(object).attr(attributeName, value); - - return value; - } - - return jQuery(object).attr(attributeName); - } - ,removeAttr: function(object, attributeName){ - jQuery(object).removeAttr(attributeName); - - return object; - } - ,html: function(element, htmlString){ - jQuery(element).html(htmlString); - - return element; - } - ,text: function(element, text){ - jQuery(element).text(text); - - return element; - } - ,manipulation: { - append: function(elementToAppend, parentElement){ - jQuery(parentElement).append(elementToAppend); - - return elementToAppend; - } - ,clone: function(object){ - return jQuery(object).clone(false)[0]; - } - ,create: function(elementName, properties){ - return jQuery('<' + elementName + ' />', properties); - } - ,createFromString: function(htmlString){ - var - html= jQuery(htmlString) - ; - - return html.length > 1 ? html.get() : html.get(0); - } - ,filter: function(elements, filterExpression){ - return jQuery(elements).filter(filterExpression); - } - ,replace: function(firstElement, secondElement){ - jQuery(firstElement).replaceWith(secondElement); - - return firstElement; - } - } - // events naming follow jquery convention, stripping down the initial 'on' and keeping everything lower case - // e.g. onClick -> click, onSubmit -> submit - ,events: { - addListener: function(object, eventName, callback){ - - if(builtins.isArray(object)) { - - builtins.forEach(object, function(){ - jQuery(this).bind(eventName, callback); - }); - - } else { - jQuery(object).bind(eventName, callback); - } - - return object; - } - ,removeListener: function(object, eventName, callback){ - jQuery(object).unbind(eventName, callback); - - return object; - } - ,trigger: function(object, eventName, args){ - jQuery(object).trigger(eventName, args); - - return object; - } - ,delegate: function(object, eventName){ - - } - } - }); - - // shortcuts - broke.DOM.q= broke.DOM.querySelector; - broke.DOM.m= broke.DOM.manipulation; - broke.DOM.e= broke.DOM.events; -})(this);;(function(undefined){ - broke.conf.settings= { - AJAX: { - dataType: 'json' // ajax data type which returns from the server - ,async: false - ,cache: false - } - ,API_BASE_URL: '/api/' - - ,BASE_URL: '/broke' - - // cache system - // broke implements only a local storage cache backend, for now - ,CACHE_BACKEND: 'localStorage://' - ,CACHE_MIDDLEWARE_SECONDS: 600 - ,CACHE_MIDDLEWARE_KEY_PREFIX: '' - - ,DATABASES: { - 'default': { - NAME: '' - ,ENGINE: 'broke.db.engines.LocalEngine' - ,USER: '' - ,PASSWORD: '' - } - ,'remote': { - NAME: '' - ,ENGINE: 'broke.db.engines.RemoteEngine' - ,USER: '' - ,PASSWORD: '' - ,BASE_URL: '/api/' - } - } - ,DATABASE_ROUTERS: ['broke.db.routers.DefaultRouter'] - - ,DISALLOWED_USER_AGENTS: [] - - ,DEBUG: false - ,CONTEXT_PROCESSORS: [] - - ,DATE_FORMAT: 'dd-mm-yy' - ,ENABLE_FETCH_REMOTE_DATA: false - ,EVENT_BINDING: 'live' // bind|live - // it should always be set to 'live' but - // at the current stage jQuery's live - // method does not alwasy work properly - - // 'EVENT_TRIGGERING_METHOD' determines the way to trigger the - // broke.events.request event - // WARNING: hashChange will work with an interval of 150ms on old browsers - // on more recent browsers will make use of the 'onhashchange' event - // which, by the time of the writing, it is only available on Firefox 3.6 and IE8 - // as for the 'elements' method please refer to the documentation under the - // 'events' topic - // choices are: elements, hashchange - ,EVENT_TRIGGERING_METHOD: 'hashchange' - - ,FILE_SYSTEM: { - SIZE: 5 * 1024 // 5 Kb default file system size - ,PERSISTENT: true - ,HOME_DIR: "/" - } - - ,FORM: null // default operation form - - ,GET_LATEST_BY: 'pk' // defines what field models' manager method - // getLatest will look at - - ,HANDLER_404: 'broke.views.defaults.pageNotFound' - - ,HASHCHANGE_INTERVAL: 150 // interval in milliseconds for the - // hashchange method to check for a changed - // url - // it's effective only if you've selected - // 'eventTriggeringMethod' as 'hashchange' - // and your browser does not support - // the 'onhashchange' event - - ,HIDE_HASH: false // whether you want the hash to be hidden - // from the main url - // careful: it will prevent any default action - // from the browser from your event - // equivalent to 'event.preventDefault();' - - ,JSON_URLS: null - - // locale specific settings - ,LOCALE_PATHS: [] - ,LANGUAGE_CODE: 'en' - ,LANGUAGES: { - 'en': 'English' - ,'it': 'Italian' - } - ,LANGUAGE_COOKIE_NAME: 'broke_language' - - ,MIDDLEWARE_CLASSES: [ - 'broke.middleware.common.CommonMiddleware' - ] - - ,PREVENT_DEFAULT: false // whether you want the broke.response to - // prevent default action from the browser - - ,PRELOAD_REMOTE_TEMPLATES: false // wether you want Broke to preload your templates - // remotely - // if set to true, Broke will attempt to download - // your templates from a remote location - // based on the basePath of your app - // e.g.: if an app's baseDir is '/myProject/apps/blog' - // and your app has a 'templates' object looks like - // { 'entry-view.html': '' }, then Broke will try to - // download '/myProject/apps/blog/templates/entry-view.html' - - ,QUERY_TYPE: 'local' // local|remote - // wether you want your query to hit a local database, - // populated with previously fetched data, - // or query the remote database - ,RETURN: location.href // form return url - - ,ROOT_URLCONF: null // a string representing the object's configuration - - ,STOP_PROPAGATION: false // whether you want the broke.response to - // prevent event propagation - - ,SAVE: { - async: false // ajax or sjax? - ,cache: false // ajax cache - ,commit: true // if you want to prevent the object to - // be saved right away, you should set this - // to false and then explicitly call the - // save method on the object with commit= true - // e.g.: entry.save({commit: true}) - // if you actually want to save it on the server - } - ,TEMPLATE_STRING_IF_INVALID: '' - ,TEMPLATE_PATHS: [] - ,TEMPLATE_LOADERS: [ - 'broke.template.loaders.apps' - ] - - // list of elements that trigger the - // broke.events.request event, setting the url - // WARNING: will only work if 'eventTriggeringMethod' is set to 'elements' - ,URL_CHANGING_ELEMENTS: { - 'a': { - events: ['click'], // events - urlAttribute: 'href' // attribute holding the url - } - ,'form': { - events: ['submit'], - urlAttribute: 'action', - preventDefault: true - } - } - ,USE_AJAX: true // would you like to use ajax? - // if false, it will create a form and - // send your data through that form - // WARNING: not ready yet! - - ,USE_I18N: false - ,USE_NAMED_URLS: false - }; -})();(function(context, undefined){ - broke.conf.urls= { - defaults: { - patterns: function(prefix) { - var - args= Array.prototype.slice.call(arguments) - ; - - return builtins.map(args.slice(1), function(){ - if(typeof this[1] == "string") { - this[1]= builtins.getattr(prefix + "." + this[1]); - } - return this; - }); - } - ,include: function(urlObject){ - if(typeof urlObject == "string") { - return builtins.getattr(urlObject); - } - return urlObject; - } - ,parseQueryString: function(queryString){ - var - result= {} - ; - - if(!queryString) { - return {}; - } - - queryString= queryString.split('&'); - - builtins.forEach(queryString, function(){ - var tmp= this.split('='); - result[tmp[0]]= tmp[1]; - }); - - return result; - } - ,parsePath: function(path){ - if(!path) { - return []; - } - - return path.split('/').slice(1); - } - } - }; -})(this);broke.contextProcessors= { - debug: function(request){ - return { - 'debug': broke.conf.settings.DEBUG - }; - }, - i18n: function(request){ - return { - 'languageCode': broke.conf.settings.LANGUAGE_CODE, - 'languages': keys(broke.conf.settings.LANGUAGES) - }; - } -};;(function(__global__, undefined){ - var - isReady= false - ,requestEventName= 'broke.request' - ,responseEventName= 'broke.response' - ,events= broke.DOM.events - ,settings= broke.conf.settings - - // utility functions - ,fireCallbacks= function(callbacks, args){ - builtins.forEach(callbacks, function(){ - this.apply(__global__, args); - }); - } - ; - - broke.events= { - isReady: function(){ - return isReady; - } - // used for internal purpose only - ,ready: function(){ - events.trigger(window, 'broke.ready'); - isReady= true; - - // make sure no one else will fires this - delete broke.events.ready; - } - ,onReady: function(fn) { - if(isReady) { - fn(); - } - - events.addListener(window, 'broke.ready', fn); - } - ,unBindOnReady: function(fn){ - if(fn === undefined) { - events.removeListener(window, 'broke.ready'); - return; - } - - events.removeListener(window, 'broke.ready', fn); - } - ,preSave: function(klass, fn){ - var - eventName= 'broke.' + klass.__name__.toLowerCase() + '.pre_save' - ; - - events.addListener(window, eventName, fn); - } - ,postSave: function(klass, fn){ - var - eventName= 'broke.' + klass.__name__.toLowerCase() + '.post_save' - ; - - events.addListener(window, eventName, fn); - } - ,bindToRequest: function(fn){ - events.addListener(window, requestEventName, fn); - } - ,bindToResponse: function(fn){ - events.addListener(window, responseEventName, fn); - } - ,request: function(args, extraArgs){ - var - req= {} - ; - - if(builtins.typeOf(args) == 'string') { - // first case: broke.events.request('/entry/view/1/'); - req.url= args; - } else { - // second case: broke.events.request({ - // url: '/entry/view/1/', - // fromReload: true - // }); - req= args; - } - - events.trigger(window, requestEventName, [req, extraArgs]); - } - ,response: function(){ - events.trigger(window, responseEventName, arguments); - } - - // some class declarations - ,Deferred: null - ,When: null - }; - - // mime jquery deferred api (CommonJS Promises/A design) - Class.create({ - __name__: "broke.events.Deferred" - - // should make these attributes private or at least very hard to access - ,_resolved: false - ,_rejected: false - ,_onSuccessCallbacks: [] - ,_onErrorCallbacks: [] - ,_onCompleteCallbacks: [] - ,_completedWithArgs: null - - ,then: function(onSuccessCallback, onErrorCallback){ - - if(this.isResolved()) { - fireCallbacks(onSuccessCallback, this._completedWithArgs); - } else if(this.isRejected()){ - fireCallbacks(onErrorCallback, this._completedWithArgs); - } - - this._onSuccessCallbacks.push(onSuccessCallback); - this._onErrorCallbacks.push(onErrorCallback); - - return this; - } - ,resolve: function(){ - if(this.isResolved()) { - // refuse to resolve an already resolved deferred - return this; - } - - fireCallbacks(this._onSuccessCallbacks, arguments); - fireCallbacks(this._onCompleteCallbacks, arguments); - - this._completedWithArgs= arguments; - - return this; - } - ,reject: function(){ - if(this.isRejected()) { - // refuse to reject an already rejected deferred - return this; - } - - fireCallbacks(this._onErrorCallbacks, arguments); - fireCallbacks(this._onCompleteCallbacks, arguments); - - this._completedWithArgs= arguments; - - return this; - } - ,isResolved: function(){ - return this._rejected; - } - ,isRejected: function(){ - return this._resolved; - } - ,always: function(){ - if(this.isResolved() || this.isRejected()) { - fireCallbacks(arguments, this._completedWithArgs); - } - - this._onCompleteCallbacks= this._onCompleteCallbacks.concat(arguments); - - return this; - } - - ,done: function(){ - if(this.isResolved()) { - fireCallbacks(arguments, this._completedWithArgs); - } - - this._onSuccessCallbacks= this._onSuccessCallbacks.concat(arguments); - - return this; - } - ,fail: function(){ - if(this.isRejected()) { - fireCallbacks(arguments, this._completedWithArgs); - } - - this._onErrorCallbacks= this._onErrorCallbacks.concat(arguments); - - return this; - } - }); - - // Request event handling - broke.events.bindToRequest(function(e, request, extraArgs, responseCallback){ - var - response= {} - ,view= null - ,callback - ,args= null - ,urlMatchResult= [] - ,partialUrl - ,target - ,parseQueryString= broke.urlResolvers.parseQueryString - ,queryString= {} - ,resolve= broke.urlResolvers.resolve - ; - - extraArgs= extraArgs || []; - - request= broke.extend({ - completeUrl: location.href, - method: 'GET', - fromReload: false, - statusCode: 200, - META: {} - }, request); - - if(request.url === undefined) { - return; - } - - // set GET/POST/REQUEST - partialUrl= request.url.split('?'); - if(partialUrl.length > 1) { - request.url= partialUrl[0]; - queryString= parseQueryString(partialUrl[1]); - - request.GET= queryString; - } else if(request.hasOwnProperty('event') - && request.event.target - && request.event.target.tagName - && request.event.target.tagName.toLowerCase() === "form"){ - - builtins.forEach(broke.DOM.q('input,select,textarea', request.event.target), function(){ - try { - queryString[broke.DOM.attr(this, 'name')]= broke.DOM.val(this); - } catch(e){} - }); - - request.POST= queryString; - } - request.REQUEST= queryString; - - // set META - request.META= { - HTTP_REFERER: location.hash.split('#')[1] || '' - }; - - // middleware fetching - builtins.forEach(broke.conf.settings.MIDDLEWARE_CLASSES, function(){ - var - middleware= builtins.getattr(this, __global__, {}) - ; - - if(middleware.processRequest !== undefined) { - middleware.processRequest.apply(this, [request].concat(extraArgs)); - } - }); - - // url dispatcher - try { - urlMatchResult= resolve(request.url); - } catch(error) { - if(error.name == "NotFound") { - //builtins.getattr(broke.conf.settings.HANDLER_404)(request); - broke.events.response(response); - return; - - } else { - throw error; - } - } - - if(urlMatchResult) { - view= urlMatchResult[0]; - args= urlMatchResult[1]; - - if(extraArgs) { - args= args.concat(extraArgs); - } - - // put the request object as the first argument - args.unshift(request); - - // create the callback function for the response to be taken - callback= function(response){ - response= broke.extend(request, response); - broke.events.response(response, extraArgs, responseCallback); - }; - - // put the callback as the last argument - args.push(callback); - - view.apply(this, args); - } - }); - - // Response event handling - broke.events.bindToResponse(function(e, response, extraArgs, responseCallback){ - - extraArgs= extraArgs || []; - - // apply additional properties - builtins.forEach(response.additionalProperties, function(key){ - response.element[key]= this; - }); - - // apply callback - if(builtins.typeOf(response.callback) == 'function') { - response.callback.apply(response.element); - } - - // --------- middleware fetching in reverse order --------- - builtins.forEach(broke.conf.settings.MIDDLEWARE_CLASSES.reverse(), function(){ - var - middleware= builtins.getattr(this, __global__, {}) - ; - - if(middleware.processResponse !== undefined) { - middleware.processResponse.apply(this, [response].concat(extraArgs)); - } - }); - }); -})(this);;(function(undefined){ - - broke.exceptions= { - NotFound: function(message){ - return { - name: "NotFound", - message: message - }; - } - ,NotImplementedError: function(message){ - return { - name: "NotImplementedError", - message: message - }; - } - ,FieldError: function(message){ - return { - name: "FieldError", - message: message - }; - } - ,NoReverseMatch: function(message){ - return { - name: "NoReverseMatch", - message: message - }; - } - ,GenericError: function(message){ - return { - name: "GenericError", - message: message - }; - } - ,ImproperlyConfigured: function(message){ - return { - name: "ImproperlyConfigured", - message: message - }; - } - ,InvalidCacheBackendError: function(message){ - return { - name: "InvalidCacheBackendError", - message: message - }; - } - ,MultipleObjectsReturned: function(message){ - return { - name: "MultipleObjectsReturned", - message: message - }; - } - ,FieldDoesNotExist: function(message){ - return { - name: "FieldDoesNotExist", - message: message - }; - } - ,DoesNotExist: function(message){ - return { - name: "DoesNotExist", - message: message - }; - } - ,SettingsObjectNotDefined: function(message){ - return { - name: "SettingsObjectNotDefined", - message: message - }; - } - ,TemplateSyntaxError: function(message){ - return { - name: "TemplateSyntaxError", - message: message - }; - } - ,TemplateDoesNotExist: function(message){ - return { - name: "TemplateSyntaxError", - message: message - }; - } - ,TemplateEncodingError: function(message){ - return { - name: "TemplateSyntaxError", - message: message - }; - } - ,VariableDoesNotExist: function(message){ - return { - name: "TemplateSyntaxError", - message: message - }; - } - }; - -})();// original: https://github.com/brokenseal/pony -;(function(__global__, undefined){ - var - Broker= function(settings){ - var - instance= this - ; - - // allow instantiation without the new keyword - if( !( this instanceof Broker ) ) { - return new Broker(settings); - } - - // private attribute, accessible only from the settings method - this.settings= mergeWithDefaultSettings(settings || {}); - - if(this.settings.queueMessages === true) { - this.messageQueue= {}; - } - - this.subscriptionList= {}; - this.subscriptionQueue= {}; - this.subscribersTokenIndex= {}; - this.messageSubscriptionTokenIndex= {}; - - if(this.settings.clearMessageQueueEvery) { - this.startClearingMessageQueue(); - } - - return this; - } - - // private shared variables - ,messageQueueObjectId= 0 - ,subscriptionToken= 0 - - /** - * - * @param object { - * instance - * message - * data - * synchronousPublish - * subscribers - * } - * @param callback - */ - ,publish= function(kwargs){ - var - messageQueue - ,instance= kwargs.instance - ,message= kwargs.message - ,data= kwargs.data - ,synchronousPublish= kwargs.synchronousPublish - ,subscribers= kwargs.subscribers - - ,publicationObject - ,returnValues= [] - ,subscribersLen - ,callbackQueue= [] - ,len - ,i - ,throwException= function(exception){ - throw exception; - } - ,deliveredMessageCount= 0 - ,deliverMessage= function(subscriber, data){ - var - returnValue - ; - - try { - returnValue= subscriber.apply(context, data); - } catch(e) { - setTimeout(throwException, 0, e); - return; - } finally { - deliveredMessageCount+= 1; - } - - if(synchronousPublish) { - returnValues.push(returnValue); - } else if(instance.settings.queueMessages === true && publicationObject) { - publicationObject.returnValues.push(returnValue); - - if(deliveredMessageCount == subscribers.length && callbackQueue.length !== 0) { - for(i= 0, len= callbackQueue.length; i < len; i++) { - callbackQueue[i](publicationObject.returnValues); - } - } - } - } - ; - - subscribers= subscribers || instance.subscriptionList[ message ]; - subscribersLen= subscribers.length; - - // if there are no subscribers available for this particular message, - // return false - if(!subscribers || !subscribers.length) { - return false; - } - - // if the user wants the messages to be queued - if(instance.settings.queueMessages === true) { - // if the message queue for this particular message does not exist yet - if(!instance.messageQueue.hasOwnProperty(message)) { - // create it - instance.messageQueue[ message ]= messageQueue= []; - } else { - // or retrieve it - messageQueue= instance.messageQueue[ message ]; - } - - // Publication object specification - // create a new message queue object - publicationObject= { - // give it a unique id - id: messageQueueObjectId++ - // the data supplied for this particular publication - ,data: data - // the amount of callbacks are subscribed to this particular message, right now - ,subscriptionCount: subscribersLen - // an array which is filled with all the return values taken from the - ,returnValues: [] - // a possible callback function which wil be fired after all the current subscribers will be - // fired - ,complete: function(fn){ - callbackQueue.push(fn); - } - }; - - // push the current publication object on to the queue - messageQueue.push(publicationObject); - } - - if(synchronousPublish) { - while(subscribersLen--) { - // deliver message right away, synchronously - deliverMessage(subscribers[subscribersLen], data); - } - } else { - while(subscribersLen--) { - // deliver message whenever possible, without blocking any - // other js or the browser UI ( http://ejohn.org/blog/how-javascript-timers-work/ ) - setTimeout(deliverMessage, 0, subscribers[subscribersLen], data) - } - } - - if(synchronousPublish) { - return returnValues; - } else if(instance.settings.queueMessages === true && publicationObject) { - return publicationObject; - } - - return true; - } - - ,unsubscribeTokenFromInstance= function(instance, subscriptionToken ) { - var - tokenIndex= instance.subscribersTokenIndex[ subscriptionToken ] - ,message= instance.messageSubscriptionTokenIndex[ subscriptionToken ] - ,unsubscribedSubscriber - ; - - unsubscribedSubscriber= instance.subscriptionList[ message ].splice(tokenIndex, 1)[0] - - if(instance.subscriptionList[ message ] === 0) { - delete instance.subscriptionList[ message ]; - } - - delete instance.subscribersTokenIndex[ subscriptionToken ]; - delete instance.messageSubscriptionTokenIndex[ subscriptionToken ]; - - return unsubscribedSubscriber; - } - ,addSubscriberToInstance= function(instance, message, subscriber){ - // double index reference for easier unsubscriptions - instance.subscribersTokenIndex[ subscriptionToken ]= instance.subscriptionList[ message ].push( subscriber ) - 1; - instance.messageSubscriptionTokenIndex[ subscriptionToken ]= message; - - return subscriptionToken; - } - // default settings - ,defaultSettings= { - // keep track of all the messages sent to the broker - // if set, any subscriber which subscribe after a message has already been sent - // will be called with this message queue as soon as it subscribes to that - // particular message - queueMessages: true - - // if set and queueMessages is set to true, it must be the number of - // seconds after which the message queue will be cleared upon instantiation - // very useful to do a garbage collection of useless messages published - ,clearMessageQueueEvery: 360 // every 5 minutes - } - - // utility functions - ,mergeWithDefaultSettings= function(settings){ - var - key - ; - - for(key in defaultSettings) { - if(!(key in settings)) { - settings[key]= defaultSettings[key]; - } - } - - return settings; - } - ; - - Broker.prototype= { - - // force contructor to be the Broker function - constructor: Broker - /** - * Broker.subscribe( message [, *args ] ) -> String | Array - * - message (String): the message to which all the given function will be subscribed to - * - *args: any amount of functions that will be subscribed - * This method subscribes all the given functions to this message and returns - * a subscription token or a list of subscription tokens, with which it is possible - * to unsubscribe all the functions - **/ - ,subscribe: function(message){ - var - subscribers= Array.prototype.slice.call(arguments).slice(1) - ,subscriptionTokenList= [] - ,i - ,subscribersLen - ,returnSubscriptionToken - ,messageQueueLen - ; - - if(!this.subscriptionList.hasOwnProperty(message)) { - this.subscriptionList[ message ]= []; - } - - if(this.settings.queueMessages === true && this.messageQueue[ message ] && this.messageQueue[ message ].length) { - messageQueueLen= this.messageQueue[ message ].length; - // deliver previously published messages to new subscribers, asynchronously by default - while(messageQueueLen--) { - publish({ - instance: this - ,message: message - ,subscribers: this.messageQueue[ message ][ messageQueueLen ].data - ,synchronousPublish: false - ,subscribers: subscribers - }, null); - } - } - - if(subscribers.length > 1) { - for(i= 0, subscribersLen= subscribers.length; i < subscribersLen; i++) { - subscriptionTokenList.push(addSubscriberToInstance(this, message, subscribers[i])); - subscriptionToken+= 1; - } - - return subscriptionTokenList; - - } else { - returnSubscriptionToken= addSubscriberToInstance(this, message, subscribers[0]); - subscriptionToken+= 1; - return returnSubscriptionToken; - } - } - - /** - * Broker.unsubscribe( subscriptionToken ) -> Function | Array - * - token (String | Array): a subscription token or a list of subscription tokens - * This method unsubscribes subscribers with the associated subscription token. - * If an array of subscription token is provided, all the token will be used to unsubscribe - * the subscribers. - * - * The return value can be the unsubscribed function or an array of unsubscribed functions - **/ - ,unsubscribe: function(subscriptionToken){ - var - subscriptionTokenLen - ,unsubscribedCallbacks - ; - - if(!subscriptionToken.length) { - unsubscribedCallbacks= unsubscribeTokenFromInstance(this, subscriptionToken); - } else { - subscriptionTokenLen= subscriptionToken.length; - unsubscribedCallbacks= []; - - while(subscriptionTokenLen--) { - unsubscribedCallbacks.push(unsubscribeTokenFromInstance(this, subscriptionToken[ subscriptionTokenLen ])); - } - } - - return unsubscribedCallbacks; - } - - /** - * Broker.publish( message [, *args ] ) -> Boolean | Array | Publication object - * - message (String): the message to publish on the current broker - * - *args: any amount of arguments, past the message - * This method publishes a particular message with any amount of data given to the function - * It then returns a false boolean if no subscriber is found for this message, - * it returns an Array of returned values from the subscribers called, - * it returns a Publication object if a queue of messages is keps inside the broker - * (please refer to the Publication object specification inside the private publish function) - * or it returns true boolean value for successfull calls - **/ - ,publish: function(message){ - var - data= Array.prototype.slice.call(arguments).slice(1) - ; - - // TODO: callback as argument or as attribute of the passed publicationObject? - - return publish({ - instance: this - ,message: message - ,data: data - ,synchronousPublish: false - }, null); - } - - /** - * Broker.publishSync( message [, *args ] ) -> Boolean - * - message (String): the message to publish on the current broker - * - *args: any amount of arguments, past the message - * This method publishes a particular message with any amount of data given to the function - **/ - ,publishSync: function(message){ - var - data= Array.prototype.slice.call(arguments).slice(1) - ; - - return publish({ - instance: this - ,message: message - ,data: data - ,synchronousPublish: true - }, null); - } - - /** - * Broker.startClearingMessageQueue( ) -> Broker instance - * It starts clearing message queue, based on the clearMessageQueueEvery setting - **/ - ,startClearingMessageQueue: function(){ - var - instance= this - ; - - // if there is no interval already set - if(!this.clearMessageQueueInterval && this.settings.clearMessageQueueEvery && this.settings.queueMessages) { - // setup a new interval for clearing messages - instance.clearMessageQueueInterval= setInterval(function(){ - instance.clearMessageQueue(); - }, this.settings.clearMessageQueueEvery * 1000); - } - - return this; - } - - /** - * Broker.startClearingMessageQueue( ) -> Broker instance - * It stop clearing message queue - **/ - ,stopClearingMessageQueue: function(){ - if(this.clearMessageQueueInterval) { - clearInterval(this.clearMessageQueueInterval); - this.clearMessageQueueInterval= null; - } - - return this; - } - - /** - * Broker.startClearingMessageQueue( ) -> Broker instance - * It clears the message queue - **/ - ,clearMessageQueue: function(){ - this.messageQueue= {}; - - return this; - } - }; - - broke.core.pubsub= { - Broker: Broker - ,broker: Broker() - }; -})(this);;(function(__global__, undefined){ - var - exceptions= broke.exceptions - ,settings= broke.conf.settings - ; - - broke.urlResolvers= { - resolve: function(url, args, urlPatterns) { - var - view= null - ,match= null - ,i - ,urlPattern - ; - - urlPatterns= urlPatterns || builtins.getattr(settings.ROOT_URLCONF); - args= args || []; - - for(i= 0; i< urlPatterns.length; i++) { - urlPattern= urlPatterns[i]; - - match= url.match(urlPattern[0]); - - if(match) { - if(match.length > 1) { - args= args.concat(match.slice(1)); - } - view= urlPattern[1]; - - if(builtins.typeOf(view) == "string") { - view= builtins.getattr(view); - } - - if(builtins.isFunction(view)) { - - return [view, args]; - - } else if(builtins.isArray(view)) { - - url= url.replace(match[0], ''); - return broke.urlResolvers.resolve(url, args, view); - - } - } - } - - throw exceptions.NotFound(gettext.gettext('Matching url not found.')); - } - ,reverse: function(namedUrl, args, urlPatterns, result) { - var - match= null - ,i - ,isInclude - ,urlPattern - ; - - urlPatterns= urlPatterns || builtins.getattr(settings.ROOT_URLCONF); - result= result || ''; - args= args || []; - - for(i= 0; i< urlPatterns.length; i++) { - urlPattern= urlPatterns[i]; - - if(builtins.typeOf(urlPattern[1]) == "string") { - urlPattern[1]= builtins.getattr(urlPattern[1]); - } - - isInclude= builtins.isArray(urlPattern[1]); - - if(isInclude) { - match= builtins.startsWith(namedUrl, urlPattern[2]); - } else { - match= (namedUrl == urlPattern[2]); - } - - if(match) { - if(isInclude) { - namedUrl= namedUrl.replace(urlPattern[2] + '-', ''); - return broke.urlResolvers.reverse(namedUrl, args, urlPattern[1], urlPattern[0]); - } else { - result+= urlPattern[0]; - result= builtins.interpolate(args, result.replace('^', '').replace('$', '').replace(/\(.*?\)/g, '%s')); - - if(result.match(urlPattern[0])) { - return result; - } else { - return ''; - } - } - } - } - - // no matching url found - throw exceptions.NoReverseMatch(gettext.gettext('Matching url not found.')); - - return null; - } - ,replaceNamedUrls: function(){ - // TODO: is this really useful? Should I refactor it to search named urls on templates only? - /* - * Search for named urls on the page and swap them with full qualified urls - * Named urls on the page should look like this: - * #entry-commit -> /blog/entry/commit/ - * #entry-view -> /blog/entry/view/2/ - * #entry-edit 21,2 -> /blog/21/entry/edit/2/ - * - * If any arguments are needed, they will have to be a comma separated - * series of values after the named url - * - */ - - var - callback= function(urlChangingElement){ - var - attr= broke.DOM.attr - ,urlAttribute= urlChangingElement.urlAttribute - ,urlToRender= attr(this, urlAttribute).split('#')[1] || '' - ,namedUrl - ,args - ,result - ; - - if(attr(this, urlAttribute).contains('#')) { - urlToRender= urlToRender.trim().split(' '); - - namedUrl= urlToRender[0]; - args= urlToRender[1]; - if(args) { - args= args.split(','); - } else { - args= []; - } - - try { - - result= broke.urlResolvers.reverse(namedUrl, args); - attr(this, urlAttribute, '#' + result); - - } catch(e) { - if(e.name == "NoReverseMatch") { - return; - } - } - } - } - ; - - builtins.forEach(broke.conf.settings.URL_CHANGING_ELEMENTS, function(key){ - var - elements= broke.DOM.querySelector(key) - ,elementsLength= elements.length - ; - - while(elementsLength--) { - callback.call(elements[elementsLength], this); - } - }); - } - }; -})(this);(function(context, undefined){ - var - remoteModels= [ - 'SlideContent' - ,'Event' - ,'PageTour' - //,'PageTourStep' - ] - ,remoteModelsForRead= remoteModels.concat([]) - ,remoteModelsForWrite= remoteModels.concat([ - 'Occurrence' - //,'Slide' - ]) - ; - - broke.db.routers= {}; - - Class.create({ - __name__: "broke.db.routers.DefaultRouter" - ,dbForRead: function(model, hints){ - if(builtins.has(remoteModelsForRead, model.__name__)) { - return 'remote'; - } - } - ,dbForWrite: function(model, hints){ - if(builtins.has(remoteModelsForWrite, model.__name__)) { - return 'remote'; - } - } - }); -})(this);;(function(undefined){ - var - JSONSchemaStorage= {} // the actual JSON used to store data - ,JSONSchemaModelStorageMapping= {} - ,cleanData= function(kwargs, model){ - var - result= kwargs - ,defaultPistonAttributeFieldsHolder - ; - - if(model) { - defaultPistonAttributeFieldsHolder= model.__name__.toLowerCase() + '_ptr'; - } - - if(defaultPistonAttributeFieldsHolder && kwargs[defaultPistonAttributeFieldsHolder]) { - // support for default django piston json emitter - result= { - pk: kwargs[defaultPistonAttributeFieldsHolder].pk - ,fields: kwargs[defaultPistonAttributeFieldsHolder] - }; - - } else if(!kwargs.fields) { - // support for generic json emitter (???) - - result= { - pk: kwargs.pk - ,fields: kwargs - }; - - } - - return result; - } - ; - - broke.storages= { - // TODO: change this with IndexedDb if available (?) - JSONSchema: { - index: {} - ,position: {} - ,autoPk: 0 - ,initTableForModel: function(model, objects){ - var - tableName= model.getTableName() - ; - - if(JSONSchemaStorage[tableName] === undefined) { - JSONSchemaStorage[tableName]= objects || []; - } - - // init pk index for this table - broke.storages.JSONSchema.index[tableName]= {}; - - JSONSchemaModelStorageMapping[tableName]= model; - - return JSONSchemaStorage[tableName]; - } - ,getTable: function(tableName){ - return JSONSchemaStorage[tableName]; - } - ,get: function(pk, tableName){ - // TODO: improve - broke.storages.JSONSchema.index[tableName]= broke.storages.JSONSchema.index[tableName] || {}; - - return broke.storages.JSONSchema.index[tableName][pk]; - } - ,set: function(tableName, kwargs) { - var - dbTable= JSONSchemaStorage[tableName] - ,i= dbTable.length - ,obj= this.get(kwargs.pk, tableName) - ,model= JSONSchemaModelStorageMapping[tableName] - ,position - ; - - kwargs= cleanData(kwargs, model); - - if(!kwargs.pk) { - kwargs.pk= null; - broke.log("Objects must have a primary key!"); - } - - if(kwargs.pk == 'auto') { - kwargs.pk= 'new_' + broke.storages.JSONSchema.autoPk; - broke.storages.JSONSchema.autoPk+= 1; - } - - if(obj) { - position= broke.storages.JSONSchema.position[kwargs.pk]; - dbTable[position]= kwargs; - obj= kwargs; - } else { - kwargs._meta= { - model: model - }; - - broke.storages.JSONSchema.index[tableName][kwargs.pk]= kwargs; - position= dbTable.push(kwargs); - broke.storages.JSONSchema.position[kwargs.pk]= position-1; - } - - return kwargs; - } - ,'delete': function(tableName, pk){ - var - dbTable= JSONSchemaStorage[tableName] - ,position= broke.storages.JSONSchema.position[pk] - ; - - builtins.remove(dbTable, position); - } - } - ,localStorage: (function(){ - // mime or reference HTML 5's Local Storage - var - localStorageSetObject= function(key, value) { - this.setItem(key, JSON.stringify(value)); - } - ,localStorageGetObject= function(key) { - return JSON.parse(this.getItem(key)); - } - ,storage= {} - ; - - if('localStorage' in window) { - broke.extend(Storage.prototype, { - set: localStorageSetObject - ,get: localStorageGetObject - }); - - return localStorage; - } - - return { - key: function(key){ - throw { - name: "NotImplementedError", - description: "Sorry, this version of localStorage is a fake and does not support key() method." - }; - } - ,setItem: function(key, value){ - storage[key]= value; - return this; - } - ,getItem: function(key){ - return storage[key]; - } - ,removeItem: function(key){ - delete storage[key]; - return this; - } - ,get: localStorageGetObject - ,set: localStorageSetObject - ,clear: function(){ - storage= {}; - return this; - } - }; - })() - }; -})();;(function(undefined){ - var - settings= broke.conf.settings - ,NotImplementedError= broke.exceptions.NotImplementedError - ,BaseEngine - ,LocalEngine - ,OPERATIONS= { - SELECT: 'select' - ,INSERT: 'insert' - ,UPDATE: 'update' - ,DELETE: 'delete' - } - ,filterOperations= { - contains: function(first, second){ - if(first.match(second)) { - return true; - } - return false; - } - ,iContains: function(first, second){ - return this.contains(first.toString().toLowerCase(), second.toString().toLowerCase()); - } - ,startsWith: function(first, second){ - if(first.match("^" + second)) { - return true; - } - return false; - } - ,iStartsWith: function(first, second){ - return this.startsWith(first.toString().toLowerCase(), second.toString().toLowerCase()); - } - ,endsWith: function(first, second){ - if(first.match(second + "$")) { - return true; - } - return false; - } - ,iEndsWith: function(first, second){ - return this.EndsWith(first.toString().toLowerCase(), second.toString().toLowerCase()); - } - ,exact: function(first, second){ - if(first.match("^" + second + "$")) { - return true; - } - return false; - } - ,iExact: function(first, second){ - return this.exact(first.toString().toLowerCase(), second.toString().toLowerCase()); - } - ,'in': function(first, second){ - return builtins.has(second, first); - } - ,gt: function(first, second){ - return first > second; - } - ,gte: function(first, second){ - return first >= second; - } - ,lt: function(first, second){ - return first < second; - } - ,lte: function(first, second){ - return first <= second; - } - ,regex: function(first, second){ - return first.match(second); - } - ,iRegex: function(first, second){ - return this.regex(first.toString().toLowerCase(), second.toString().toLowerCase()); - } - ,isNull: function(first, second) { - return (first === null || first === undefined) ? second : !second; - } - ,year: function(first, second) { - return (new Date(first).getFullYear()) == second; - } - ,month: function(first, second) { - return (new Date(first).getMonth() + 1) == second; - } - ,day: function(first, second) { - return (new Date(first).getDate()) == second; - } - ,weekDay: function(first, second) { - return (new Date(first).getDay()) == second; - } - ,range: function(first, second) { - return (second[0] <= first) && (first <= second[1]); - } - } - ,applyFilters= function(engine, data, args, negate){ - var - Model= broke.db.models.Model - ; - negate= negate === undefined ? true : negate; - - return builtins.filter(data, function(){ - var - splitData= null - ,filterOperation= null - ,key= null - ,newKey= null - ,relatedObjectFilterOptions= {} - ,relatedResult - ,value - ,data= this - ; - - for(key in args) { - if(args.hasOwnProperty(key)) { - - /*if(!(key in this.fields)) { - throw broke.exceptions.FieldError(builtins.interpolate(gettext.gettext("The specified field (%s) is not available."), key)); - }*/ - - splitData= key.split('__'); - - if(splitData.length > 1) { - newKey= splitData[0]; - filterOperation= splitData[1]; - - if(filterOperation in filterOperations) { - - if(!filterOperations[filterOperation](this.fields[newKey], args[key])) { - return !negate; - } - - } else if(builtins.typeOf(this.fields[newKey]) == "object"){ - try { - relatedResult= builtins.getattr(splitData.join('.'), this.fields, null); - - if(relatedResult == args[key]) { - return negate; - } - - } catch(e) {} - - return !negate; - - } else { - throw broke.exceptions.NotImplementedError(builtins.interpolate(gettext.gettext("Filter operation '%s' not implemented."), filterOperation)); - } - } else if(args[key] instanceof Model && this.fields[key] instanceof Model) { - try { - if(args[key].pk != this.fields[key].pk) { - return !negate; - } - } catch(e) {} - - return negate; - - } else if(key == "pk" && this[key] == args[key]) { - return negate; - } else if(this.fields[key] != args[key]) { - return !negate; - } - } - } - return negate; - }); - } - ,saveRelatedObjectsOnLocalEngine= function(objects){ - - builtins.forEach(objects, function(){ - var - object= this - ; - - builtins.forEach(this.fields, function(key){ - var - relatedField - ; - - if(builtins.typeOf(this) == "array") { - relatedField= object[key]; - - if(relatedField) { - builtins.forEach(this, function(){ - LocalEngine({ - model: relatedField.model - ,args: { - insert: this - } - ,operation: OPERATIONS.INSERT - }).execute(); - }); - } - } - - }); - - }); - } - ; - - broke.db.engines= { - OPERATIONS: OPERATIONS - }; - - BaseEngine= Class.create({ - __name__: "broke.db.engines.BaseEngine" - ,__init__: function(kwargs){ - this.model= kwargs.model; - this.args= kwargs.args; - this.operation= kwargs.operation; - this.settings= kwargs.settings; - this.object= kwargs.object; - } - ,select: function(){ - throw NotImplementedError("You need to implement this method on every class that extends this one."); - } - ,insert: function(){ - throw NotImplementedError("You need to implement this method on every class that extends this one."); - } - ,update: function(){ - throw NotImplementedError("You need to implement this method on every class that extends this one."); - } - ,'delete': function(){ - throw NotImplementedError("You need to implement this method on every class that extends this one."); - } - ,execute: function(callback){ - var - engine= this - ,executeCallback= function(operationResult, status, xhr, error){ - var - result - ; - - if(operationResult && builtins.typeOf(operationResult) == "array") { - - result= builtins.map(operationResult, function(){ - return engine.model(this); - }); - - saveRelatedObjectsOnLocalEngine(result); - - } else if(builtins.typeOf(operationResult) == "object") { - result= engine.model(operationResult); - - saveRelatedObjectsOnLocalEngine([result]); - } - - if(callback) { - callback(result, status, xhr, error); - } - } - ; - - return this[this.operation](executeCallback); - } - }); - - LocalEngine= BaseEngine.create({ - __name__: "broke.db.engines.LocalEngine" - ,storage: broke.storages.JSONSchema - ,select: function(callback){ - var - data= this.storage.getTable(this.model.getTableName()) - ; - - data= applyFilters(this, data, this.args.filter); - data= applyFilters(this, data, this.args.exclude, true); - - callback(data); - } - ,insert: function(callback){ - var - engine= this - ,objects - ,dataTableName= this.model.getTableName() - ,data - ; - - if(builtins.typeOf(this.args.insert) == "array") { - data= []; - - builtins.forEach(this.args.insert, function(){ - data.push(this.storage.set(dataTableName, this)); - }); - } else { - data= this.storage.set(dataTableName, this.args.insert); - } - - callback(data); - } - ,update: function(callback){ - return this.insert(callback); - } - ,'delete': function(callback){ - // TODO - } - ,orderBy: function(){ - // TODO - /* - var - index= this.length - ,fieldValueList= [] - ,tmpValue - ,querySet= this - ; - - //if(typeOf(field) != 'string' && typeOf(field) != 'number') { - // throw new TypeError('Order by works with strings and number types only!'); - //} - - while(index--) { - tmpValue= querySet[index].fields[field]; - tmpValue= new tmpValue.constructor(tmpValue); - - tmpValue.__index__= index; - fieldValueList.push(tmpValue); - } - fieldValueList.sort(); - - builtins.forEach(fieldValueList, function(){ - var - obj= querySet[this.__index__] - ; - - delete this.__index__; - - querySet.push(obj); - }); - - */ - - return this; - } - }); - LocalEngine.initTableForModel= function(model, objects){ - return this.prototype.storage.initTableForModel(model, objects); - }; - - RemoteEngine= BaseEngine.create({ - __name__: "broke.db.engines.RemoteEngine" - ,select: function(callback){ - return this._ajaxOperation({ - data: this.args.filter - ,type: 'GET' - //,success: function(data, status, xhr){ - // callback(data, status, xhr); - //} - },callback); - } - ,insert: function(callback){ - return this._ajaxOperation({ - data: this.args.insert.fields - ,type: 'POST' - ,success: function(data, status, xhr){ - data= builtins.typeOf(data) == "array" ? data[0] : data; - - if(callback){ - callback(data, status, xhr, null); - } - } - }, callback); - } - ,update: function(callback){ - return this._ajaxOperation({ - data: this.args.update - ,type: 'PUT' - ,url: this.object.remoteUrls.update - ,success: function(data, status, xhr){ - data= builtins.typeOf(data) == "array" ? data[0] : data; - - if(callback){ - callback(data, status, xhr); - } - } - }, callback); - } - ,'delete': function(callback){ - return this._ajaxOperation({ - type: 'DELETE' - ,url: this.object.remoteUrls['delete'] - }, callback); - } - ,orderBy: function(){ - // TODO - } - ,_ajaxOperation: function(ajaxSettings, callback){ - ajaxSettings= broke.extend({ - async: this.settings.async - ,cache: this.settings.cache === undefined ? false : this.settings.cache - ,url: this.model.getBaseRemoteUrl() - ,success: function(data, status, xhr){ - if(callback){ - callback(data, status, xhr); - } - } - ,error: function(xhr, status, error){ - if(callback){ - callback(null, status, xhr, error); - } - } - }, ajaxSettings); - - return $.ajax(ajaxSettings); - } - }); -})();(function(context, undefined){ - var - Field - ,ForeignKey - ,CharField - ,TextField - ,BooleanField - ,PositiveIntegerField - ,getter= function(){} - ,setter= function(){} - ; - - Field= Class.create({ - __name__: "broke.db.fields.Field" - ,__init__: function(kwargs){ - this['default']= kwargs['default']; - } - ,get: function(instance){ - return instance.fields[this.fieldName] || this['default']; - } - ,attachCurrentModelInstance: true - ,contributeToClass: function(cls, fieldName){ - //this.setAttributesFromName(fieldName); - this.model= cls; - this.fieldName= fieldName; - } - }); - - ForeignKey= Field.create({ - __name__: "broke.db.fields.ForeignKey" - ,__init__: function(kwargs){ - this._super(kwargs); - - this.relatedModel= kwargs.model; - if(kwargs.relatedName) { - this.relatedName= kwargs.relatedName; - } - } - ,contributeToClass: function(cls, fieldName){ - this._super(cls, fieldName); - this.contributeToRelatedClass(cls, fieldName); - } - ,contributeToRelatedClass: function(cls, fieldName){ - var - fieldInstance= this - ,getRelatedModels= function(){ - return cls.objects.filter({ - pk: this.instance.fields[fieldName] - }); - } - ; - - if(!this.relatedName) { - this.relatedName= cls.__name__.toLowerCase() + '_set'; - } - - this.relatedModel.prototype[this.relatedName]= getRelatedModels; - - // is it the best way to handle this? not sure... - getRelatedModels.model= cls; - } - ,get: function(instance, callback){ - var - pk= instance.fields[this.fieldName] || instance.fields[this.fieldName + '_id'] - ; - - this.relatedModel.objects.get({ - pk: pk - }, callback); - } - }); - - PositiveIntegerField= Field.create({ - __name__: "broke.db.fields.PositiveIntegerField" - ,set: function(instance, value){ - if(value < 0 || parseInt(value) === NaN) { - throw new Error("A PositiveIntegerField only accepts a positive integer field."); - } - - instance.fields[this.fieldName]= value; - - return value; - } - }); - - BooleanField= Field.create({ - __name__: "broke.db.fields.BooleanField" - ,set: function(instance, value){ - if(builtins.typeOf(value) != "boolean") { - throw new Error("A BooleanField only accepts a boolean values."); - } - - instance.fields[this.fieldName]= value; - - return value; - } - }); - - TextField= Field.create({ - __name__: "broke.db.fields.TextField" - ,set: function(instance, value){ - instance.fields[this.fieldName]= value; - - return value; - } - }); - - CharField= TextField.create({ - __name__: "broke.db.fields.CharField" - ,__init__: function(kwargs){ - this._super(kwargs); - - this.max_length= kwargs.max_length; - } - ,set: function(instance, value){ - if(value.length > this.max_length) { - throw new Error("Value exceeds set max length"); - } - instance.fields[this.fieldName]= value; - - return value; - } - }); - - // TODO: DateField - - // make all the fields available as broke.db.models attributes - broke.extend(broke.db.models, broke.db.fields); -})(this);(function(){ - var - QuerySet - ,engineOperations= broke.db.engines.OPERATIONS - ,settings= broke.conf.settings - ; - - /*************************************************************************/ - /************************** BASE QUERYSET CLASS **************************/ - /*************************************************************************/ - QuerySet= Class.create({ - __name__: "broke.db.models.QuerySet" - ,__init__: function(kwargs){ - var - routers= settings.DATABASE_ROUTERS - ,routersLen= routers.length - ,i - ,dbForRead - ,dbForWrite - ,router - ; - - this.model= kwargs.model; - this.db= kwargs.db; - this.args= { - filter: {} - ,exclude: {} - ,insert: {} - ,orderBy: {} - ,'delete': {} - }; - this._settings= kwargs.settings || {}; - - broke.extend(this.args, kwargs.args); - - if(this.db) { - this.dbForRead= this.db; - this.dbForWrite= this.db; - } else { - this.dbForRead= broke.db.models.getDbForReadFromModel(this.model); - this.dbForWrite= broke.db.models.getDbForWriteFromModel(this.model); - } - - this.engineForRead= builtins.getattr(settings.DATABASES[this.dbForRead].ENGINE); - this.engineForWrite= builtins.getattr(settings.DATABASES[this.dbForWrite].ENGINE); - } - ,settings: function(settings){ - broke.extend(this._settings, settings); - - return this; - } - ,exclude: function(args){ - this.args.exclude= args; - - return this.__class__({ - model: this.model - ,args: this.args - ,settings: this._settings - ,db: this.db - }); - } - ,filter: function(args){ - this.args.filter= args; - - return this.__class__({ - model: this.model - ,args: this.args - ,settings: this._settings - ,db: this.db - }); - } - ,create: function(args, callback){ - if(builtins.typeOf(args) == "function") { - callback= args; - args= undefined; - } - this.args.insert= args; - - this.engineForWrite({ - operation: engineOperations.INSERT - ,model: this.model - ,args: this.args - ,settings: this._settings - }).execute(callback); - } - ,getOrCreate: function(args, callback){ - try { - return this.get(args, callback); - } catch(e) { - if(e.name == 'DoesNotExist') { - return this.create(args); - } - - throw e; - } - } - ,get: function(args, callback){ - var - querySet= this - ,getCallback= function(object){ - if(object.length > 1) { - throw broke.exceptions.MultipleObjectsReturned(builtins.interpolate(gettext.gettext("get() returned few %s instances -- it returned %s! Lookup parameters were %s"), querySet.model.__name__, object.length, args)); - } - if(!object.length) { - throw broke.exceptions.DoesNotExist(builtins.interpolate(gettext.gettext("%s matching query does not exist."), querySet.model.__name__)); - } - - if(callback){ - callback(object[0]); - } - } - ; - - if(callback === undefined) { - callback= args; - args= undefined; - } - - if(args) { - this.filter(args).all(getCallback); - } else { - this.all(getCallback); - } - } - ,latest: function(field, callback){ - if(callback === undefined) { - callback= field; - field= undefined; - } - field= field || settings.GET_LATEST_BY; - - return this.orderBy(field).all(callback)[0]; - } - ,orderBy: function(fields){ - if(builtins.typeOf(fields) == "string") { - fields= [ fields ]; - } - this.args.orderBy= fields; - - return this.__class__({ - model: this.model - ,args: this.args - ,settings: this._settings - ,db: this.db - }); - } - ,all: function(settings, callback){ - if(callback === undefined) { - callback= settings; - settings= undefined; - } - - this.engineForRead({ - operation: engineOperations.SELECT - ,model: this.model - ,args: this.args - ,settings: this._settings - }).execute(callback); - } - ,'delete': function(callback){ - this.engineForWrite({ - operation: engineOperations.DELETE - ,model: this.model - ,args: this.args - ,settings: this._settings - }).execute(callback); - } - }); -})(); -(function(){ - var - LocalQuerySet= broke.db.models.LocalQuerySet - RemoteQuerySet= broke.db.models.RemoteQuerySet - ,QUERY_TYPE= broke.conf.settings.QUERY_TYPE - ; - - /*************************************************************************/ - /****************************** MANAGER **********************************/ - /*************************************************************************/ - Class.create({ - __parent__: window - ,__name__: "broke.db.models.Manager" - ,__init__: function(model){ - this.model= model; - } - ,all: function(callback){ - return this.getQuerySet().all(callback); - } - ,create: function(args, callback){ - return this.getQuerySet().create(args, callback); - } - ,exclude: function(args){ - return this.getQuerySet().exclude(args); - } - ,filter: function(args){ - return this.getQuerySet().filter(args); - } - ,get: function(args, callback){ - return this.getQuerySet().get(args, callback); - } - ,getOrCreate: function(args, callback){ - return this.getQuerySet().getOrCreate(args, callback); - } - ,getQuerySet: function(){ - return new broke.db.models.QuerySet({ model: this.model, db: this.db }); - } - ,settings: function(settings){ - return this.getQuerySet().settings(settings); - } - ,latest: function(args, callback){ - return this.getQuerySet().latest(args, callback); - } - ,using: function(db){ - this.db= db; - return this; - } - }); -})(); -;(function(undefined){ - var - Model - ,models= broke.db.models - ,Manager= models.Manager - ,elementsCache= {} - ,contentTypeCache= {} - ; - - broke.extend(broke.db.models, { - addContentType: function(appLabel, modelName, model){ - if(contentTypeCache[appLabel] === undefined) { - contentTypeCache[appLabel]= {}; - } - - contentTypeCache[appLabel][modelName]= model; - } - ,getDbFromModel: function(operation, model){ - var - routers= broke.conf.settings.DATABASE_ROUTERS - ,routersLen= routers.length - ,db - ; - - // retrieve db for read - for(i= 0; i< routersLen; i++) { - router= builtins.getattr(routers[i])(); - db= router[operation](model); - - if(db) { - return db; - } - } - - return 'default'; - } - ,getDbForReadFromModel: function(model){ - return broke.db.models.getDbFromModel('dbForRead', model); - } - ,getDbForWriteFromModel: function(model){ - return broke.db.models.getDbFromModel('dbForWrite', model); - } - ,getModel: function(appLabel, modelName){ - return contentTypeCache[appLabel][modelName]; - } - ,compareObjects: function(firstObject, secondObject){ - if(firstObject.__class__.__fullname__ == secondObject.__class__.__fullname__ && firstObject.pk == secondObject.pk) { - return true; - } - - return false; - } - ,fetchDataForModel: function(model, args){ - // TODO: is this still useful? if yes, it needs refactor - var - settings= broke.conf.settings - ,url= args.url || builtins.interpolate(settings.JSON_URLS.getData, { - appLabel: model.appLabel - ,model: model.className.toLowerCase() - }) - ,filter= args.filter || {} - ,result - ,defaultDbEngine= builtins.getattr(settings.DATABASES['default'].ENGINE); - ; - - $.ajax({ - async: false, - type: "GET", - url: url, - data: filter, - dataType: settings.AJAX.dataType, - error: function(xhr, status, error){ - result= error; - }, - success: function(data, status){ - defaultDbEngine.initTableForModel(model, data); - result= data; - } - }); - - return result; - } - }); - - /*************************************************************************/ - /******************************* MODEL ***********************************/ - /*************************************************************************/ - - Class.create({ - __name__: "broke.db.models.ModelMetaClass" - ,__init__: function(__class__){ - var - defaultManager - ,currentModel= this - ; - - __class__.objects= Manager(__class__); - __class__.appLabel= __class__.__fullname__.split('.').slice(-3, -2)[0]; - - currentModel._meta.appLabel= __class__.appLabel; - currentModel._meta.modelName= __class__.__name__.toLowerCase(); - - // init fields which contribute to the class - builtins.forEach(__class__.prototype, function(key){ - if(this instanceof Manager && defaultManager === undefined) { - defaultManager= this; - } - -// if(this._field) { -// currentModel._meta.fields[key]= this; -// } - - if(this.contributeToClass) { - this.contributeToClass(__class__, key); - } - }); - - __class__._defaultManager= defaultManager || __class__.objects; - } - ,_meta: { - fields: {} - } - // exceptions - ,DoesNotExist: broke.exceptions.DoesNotExist - ,MultipleObjectsReturned: broke.exceptions.MultipleObjectsReturned - ,getTableName: function(){ - if(!this._tableName){ - this._tableName= [this.appLabel, this.__name__.toLowerCase()].join('_'); - } - - return this._tableName; - } - ,getObjectFromElement: function(element, callback){ - var - model - ,objectPk= element.attr('data-pk') - ,appLabel= element.attr('data-app_label') - ,model= this.__name__.toLowerCase() - ; - - models.getModel(appLabel, model)._defaultManager.getOrCreate({ pk: objectPk }, callback); - } - ,getBaseRemoteUrl: function(){ - if(!this._remoteBaseUrl) { - this._remoteBaseUrl= broke.conf.settings.API_BASE_URL + this.__name__.toLowerCase() + '/' - } - - return this._remoteBaseUrl; - } - }); - - Model= Class.create({ - __name__: "broke.db.models.Model" - ,__metaclass__: broke.db.models.ModelMetaClass - ,__init__: function(args, inheritedFields){ - var - baseUrl= this.__class__.getBaseRemoteUrl() - ,currentInstance= this - ,tmpArgs - ,key - ; - - // TODO: add a an adapter for piston and django type of data - if(args.fields === undefined) { - tmpArgs= {}; - tmpArgs.fields= args; - tmpArgs.pk= args.pk || args.id; - args= tmpArgs; - } - - // extend current object - broke.extend(this, args || {}); - - // init primary key - if(this.pk) { - this.fields.pk= this.pk; - } - - // init remote urls - this.remoteUrls= { - get: baseUrl - ,save: baseUrl - ,update: baseUrl + this.pk + '/' - ,'delete': baseUrl + this.pk + '/' - }; - - // attach the current instance to all the fields of this model's instance - builtins.forEach(this.__class__.prototype, function(key){ - var - field - ; - - if(this instanceof broke.db.fields.Field) { - - field= this; - - currentInstance[key]= function(value){ - if(value !== undefined) { - return field.set(currentInstance, value); - } else { - return field.get(currentInstance); - } - } - - } - }); - } - ,fields: {} - ,elements: function(kwargs){ - // element identifier : e.g. entry_21 - // TODO: change it to use content types - var - extraFilter - ,context= document - ,clearCache - ,elements - ,filterExpression - ; - - if(kwargs) { - extraFilter= kwargs.filter || ''; - context= kwargs.context || document; - clearCache= kwargs.clearCache; - filterExpression= kwargs.filterExpression || ''; - } - - filterExpression= filterExpression || '[data-pk="' + this.fields.pk + '"]'+ - '[data-app_label="' + this.__class__.appLabel + '"]'+ - '[data-model="' + this.__class__.__name__.toLowerCase() + '"]'; - - clearCache= clearCache === undefined ? false : clearCache; - - if(!elementsCache[filterExpression]) { - clearCache= true; - } - - if(clearCache) { - elements= broke.DOM.querySelector(filterExpression, context); - - if(extraFilter) { - elements= broke.DOM.m.filter(elements, extraFilter); - } - - elementsCache[filterExpression]= elements; - } - - return elementsCache[filterExpression]; - } - ,getForm: function(formSetParent){ - if(!this.form) { - this.form= broke.forms.Form({ - instance: this - ,formSetParent: formSetParent - }); - } - - return this.form; - } - ,getAbsoluteUrl: function(){ - return ''; - } - ,getOperation: function(del){ - if(del !== undefined && this.fields.pk) { - return 'delete'; - } - else if(this.fields.pk) { - return 'update'; - } - - return 'create'; - } - ,processFields: function(){ - var - data= {} - ; - - builtins.forEach(this.fields, function(key){ - if(this instanceof Model) { - - data[key]= this.pk.toString(); - - } else if(builtins.typeOf(this) == "object" && (this.pk || this.id)) { - data[key]= this.pk || this.id; - } else if(builtins.startsWith(key, '_')) { - // do nothing - - return; - } else if(this !== undefined) { - - data[key]= this.toString(); - - } - }); - - return data; - } - ,update: function(fields, updateDOM){ - var - instance= this - ; - updateDOM= updateDOM === undefined ? true : updateDOM; - - broke.extend(this.fields, fields); - - if(updateDOM) { - // asynchronously update instance's elements - setTimeout(function(){ - var - elements= instance.elements({ clearCache: true }) - ; - - builtins.forEach(fields, function(key){ - var - result= broke.DOM.querySelector('[data-field="' + key + '"]', elements) - ; - - if(builtins.typeOf(this) == "boolean") { - if(this == true) { - broke.DOM.attr(result, 'checked', 'checked'); - } else { - broke.DOM.removeAttr(result, 'checked'); - } - } else { - broke.DOM.text(result, this); - } - }); - }, 0); - } - - return this; - } - ,save: function(saveSettings, callback){ - // TODO: clean up this mess - var - object= this - ,className= object.__class__.__name__.toLowerCase() - ,operation - ,serverOperation - ,apiBaseUrl= broke.conf.settings.API_BASE_URL - ,operationsMap= { - 'save': 'POST' - ,'update': 'PUT' - ,'delete': 'DELETE' - } - ,data= {} - ,created= true - ,overrideLocalData - ,using - ,dbForWrite - ,engineForWrite - ,engineOperation= 'insert' - ,engineOperationArgs= { - insert: {} - ,update: {} - ,'delete': {} - } - ; - - if(builtins.typeOf(saveSettings) == 'function') { - callback= saveSettings; - saveSettings= {}; - } - - saveSettings= saveSettings || {}; - url= saveSettings.url || apiBaseUrl + className + '/'; - overrideLocalData= saveSettings.overrideLocalData === undefined ? true : saveSettings.overrideLocalData; - - // using - dbForWrite= saveSettings.using; - - // load defaults on save settings - saveSettings= broke.extend(builtins.clone(broke.conf.settings.SAVE), saveSettings); - - operation= saveSettings.operation ? 'delete' : 'save'; - - // trigger model pre_save event - broke.DOM.events.trigger(window, 'broke.' + className + '.pre_' + operation, [object]); - - if(operation == 'save' && object.pk) { - serverOperation= 'update'; - engineOperation= 'update'; - } else if(operation == 'save') { - engineOperation= 'insert'; - } else if(operation == 'delete' && !object.pk){ - // TODO - //throw new Error("? ^^"); - } else { - serverOperation= operation; - engineOperation= operation; - } - - if(this.pk && operation != 'save') { - url += object.pk + '/'; - } - - data= this.processFields(); - engineOperationArgs[engineOperation]= data; - - dbForWrite= dbForWrite !== undefined ? dbForWrite : broke.db.models.getDbForWriteFromModel(this.__class__); - engineForWrite= builtins.getattr(broke.conf.settings.DATABASES[dbForWrite].ENGINE); - - // mark this object as being deleted - this.fields._deleted= true; - - if(saveSettings.commit) { - return engineForWrite({ - operation: engineOperation - ,model: this.__class__ - ,object: this - ,args: engineOperationArgs - ,settings: saveSettings - }).execute(function(data, status, xhr, error){ - - broke.DOM.events.trigger(window, 'broke.' + className + '.post_' + engineOperation, [object]); - - if(callback) { - callback(data); - } - - }); - } - } - ,'delete': function(settings, callback){ - var - instance= this - ; - - if(builtins.typeOf(settings) == "function") { - callback= settings; - settings= {}; - } - settings= settings || {}; - - this.fields._deleted= true; - - settings.operation= 'delete'; - - setTimeout(function(){ - instance.elements({ clearCache: true }).remove(); - }, 0); - - return this.save(settings, callback); - } - }); - - builtins.forEach(broke.db.fields, function(key){ - broke.db.models[key]= this; - }); -})();broke.forms= {};(function(){ - var - saveAsAjaxRequest= function(data){ - var result; - - $.ajax({ - async: false - ,method: 'POST' - ,data: data - ,success: function(status){ - result= status; - } - ,error: function(status){ - result= status; - } - }); - - return result; - } - ,saveAsFormPost= function(data){ - var - form= broke.DOM.m.create('form', { - action: '.' - ,method:'post' - ,style:'display:none;' - }) - ,field= broke.DOM.m.create('textarea') - ,newField - ,body= broke.DOM.m.querySelector('body') - ; - - builtins.forEach(data, function(key){ - newField= broke.DOM.m.clone(field); - broke.DOM.attr(newField, 'name', key); - - if(builtins.typeOf(this) == "boolean") { - if(this == true) { - broke.DOM.val(newField, 'on'); - broke.DOM.m.append(newField, form); - } - } else if(builtins.typeOf(this) == "array") { - builtins.forEach(this, function(){ - newField= broke.DOM.m.clone(field); - broke.DOM.val(newField, this); - broke.DOM.attr(newField, 'name', key); - broke.DOM.m.append(newField, form); - }); - } else { - broke.DOM.val(newField, this); - broke.DOM.m.append(newField, form); - } - }); - - broke.DOM.m.append(form, body); - broke.DOM.e.trigger(form, 'submit'); - - return form; - } - ; - - Class.create({ - __name__: "broke.forms.Form" - ,__init__: function(kwargs){ - /* - kwargs: { - instance - formSetParent - } - */ - - broke.extend(this, kwargs); - } - ,save: function(settings){ - var - useAjax= settings.useAjax || broke.conf.settings.useAjax - ,result - ,prefix= settings.prefix || '' - ,form= this - ,data= {} - ; - - // putting all the data from the object into the form - builtins.forEach(this.instance.getData(), function(key){ - data[prefix + key]= this; - }); - - if(this.formSetParent) { - // if this form is part of a formset, it won't post itself to the server - // but rather return itself to the formset parent's save method - return data; - - } else if(useAjax) { - - result= saveAsAjaxRequest(data); - - } else { - - result= saveAsFormPost(data); - - } - - return result; - } - }); - - Class.create({ - __name__: "broke.forms.FormSet" - ,__init__: function(kwargs){ - /* - kwargs: { - instance - relatedObjects - forms - initialForms - prefix - } - */ - - broke.extend(this, kwargs); - } - ,save: function(settings){ - var - useAjax - ,result - ,data= {} - ,commit - ,count= 0 - ,formSet= this - ; - - settings= settings || {}; - commit= settings.commit || false; - //useAjax= settings.useAjax || broke.conf.settings.AJAX; - - // formset management data - data[this.prefix+'-TOTAL_FORMS']= this.forms.length; - data[this.prefix+'-INITIAL_FORMS']= this.initialForms; - - // get this formset instance's data - broke.extend(data, this.instance.getData()); - - // formset's forms data - builtins.forEach(this.forms, function(){ - - broke.extend(data, this.save({ - prefix: formSet.prefix + '-' + count + '-' - })); - - count+= 1; - }); - - if(settings.extraData){ - broke.extend(data, settings.extraData); - } - - if(useAjax) { - - result= saveAsAjaxRequest(data); - - } else { - - result= saveAsFormPost(data); - - } - - return result; - } - }); -})();/** - * Heavily inspired by http://www.html5rocks.com/en/tutorials/file/filesystem/ - * API copied from NodeJS file system api at http://nodejs.org/docs/latest/api/fs.html which exposes standard POSIX functions - */ - -(function(__global__, undefined){ - var - requestFileSystem= __global__.requestFileSystem || __global__.webkitRequestFileSystem - ,settings= broke.conf.settings - ,KB= 1024 - ,MB= KB * KB - ,GB= MB * KB - ,TB= GB * KB - - // utility functions - ,getFileSystem= function(callback){ - var - type= settings.FILE_SYSTEM.PERSISTENT ? __global__.PERSISTENT : __global__.TEMPORARY - ; - - if(requestFileSystem === undefined) { - throw new Error("This browser does not support the HTML5 file system API."); - } - - requestFileSystem(type, settings.FILE_SYSTEM.SIZE, function(fs){ - - callback(fs); - - }, function(error){ - throw error; - }); - - } - /** - * Splits directory from file from the path given - */ - ,splitPath= function(path){ - var - tmpSplitPath= path.split('/') - ,dirPath= tmpSplitPath.slice(0, -1).join('/') - ,fileName= tmpSplitPath.slice(-1)[0] - ; - - return [ dirPath, fileName ]; - } - ; - - broke.fs= { - KB: KB - ,MB: MB - ,GB: GB - ,TB: TB - - // File.seek whence constants - ,SEEK_SET: 0 - ,SEEK_CUR: 1 - ,SEEK_END: 2 - - ,open: function(path, flags, callback){ - broke.fs.File(path, flags, callback); - } - ,unlink: function(path, callback){ - fs.root.getFile(path, { - create: false - }, function(fileEntry){ - fileEntry.remove(function(){ - callback(); - }, function(error){ - callback(error); - }); - }, function(error){ - callback(error); - }); - } - ,rename: function(fromPath, toPath, callback){ - var - tmpFromPath= splitPath(fromPath) - ,tmpToPath= splitPath(toPath) - ,fromDirectoryPath= tmpFromPath[0] - ,fromFileName= tmpFromPath[1] - ,toDirectoryPath= tmpToPath[0] - ,toFileName= tmpToPath[1] - ; - - getFileSystem(function(fs){ - fs.root.getDirectory(fromDirectoryPath, {}, function(directoryEntry){ - directoryEntry.getFile(fromFileName, {}, function(fileEntry){ - if(fromFileName !== toFileName && fromDirectoryPath === toDirectoryPath) { - // simple renaming - fileEntry.moveTo(fromDirectoryPath, toFileName); - } else if(fromFileName != toFileName && fromDirectoryPath != toDirectoryPath){ - // rename and move - fileEntry.moveTo(toDirectoryPath, toFileName); - } else if(fromDirectoryPath != toDirectoryPath){ - // simple move - fileEntry.moveTo(toDirectoryPath); - } - - callback(); - }, function(error){ - callback(error); - }); - }, function(error){ - callback(error); - }); - }); - } - ,rmdir: function(path, callback){ - getFileSystem(function(fs){ - fs.root.getDirectory(function(directoryEntry){ - directoryEntry.removeRecursively(callback, callback); - }); - }); - } - ,mkdir: function(path, callback){ - var - folders= path.split('/') - ,startDirectory - ,createDir= function(directoryEntry, directoryName){ - - // if a directory name has been passed, then create it inside the current directory - if(directoryName) { - directoryEntry.getDirectory(directoryName, { create: true }, function(newDirectoryEntry){ - // recursively call createDir - createDir(newDirectoryEntry, folders.shift()); - }, function(error){ - callback(error, null); - }); - } else { - // we reached the end of the folders, fire the callback function with the last created directory as argument - callback(null, broke.fs.Directory(directoryEntry)); - } - } - ; - - getFileSystem(function(fs){ - createDir(fs.root, folders.shift()); - }); - } - ,readdir: function(path, callback){ - getFileSystem(function(fs){ - fs.root.getDirectory(function(directoryEntry){ - var - reader= directoryEntry.createReader() - ,entries= [] - ,readEntries= function(){ - reader.readEntries(function(results){ - if(results.length) { - entries= entries.concat(Array.prototype.slice.call(results)); - - readEntries(); - } else { - callback(null, entries); - } - }); - } - ; - - readEntries(); - }, function(error){ - callback(error, null); - }); - }); - } - - // declared classes - ,Directory: null - ,File: null - ,FileSystem: null - }; - - Class.create({ - __name__: "broke.fs.File" - ,__init__: function(path, flags, callback){ - var - instance= this - ,mode= flags.charAt(0) - ,readModeEnabled - ,writeModeEnabled - ,seekToEnd - ,truncateFile - ,createFile - ,binaryModeEnabled= (/b/).test(flags) - ; - - if(mode === 'r'){ - readModeEnabled= true; - writeModeEnabled= (/[+]/).test(flags); - seekToEnd= false; - truncateFile= false; - createFile= false; - } else if(mode === 'w'){ - readModeEnabled= (/[+]/).test(flags); - writeModeEnabled= true; - seekToEnd= false; - truncateFile= true; - createFile= true; - } else if(mode === 'a'){ - readModeEnabled= (/[+]/).test(flags); - writeModeEnabled= true; - seekToEnd= true; - truncateFile= false; - createFile= true; - } else{ - readModeEnabled= false; - writeModeEnabled= false; - seekToEnd= false; - truncateFile= false; - createFile= false; - if(callback){ - // TO DO -- An error object should be passed as the first parameter - callback(true, null); - return; - } - } - - this._offset= 0; - this._file= null; - this._writer= null; - this._binaryMode= binaryModeEnabled; - - getFileSystem(function(fs){ - fs.root.getFile(path, { - create: createFile - }, function(fileEntry){ - instance._fileEntry= fileEntry; - - if(readModeEnabled) { - fileEntry.file(function(file){ - instance._file= file; - instance._slice= file.slice || file.webkitSlice; - - if((!writeModeEnabled) || (writeModeEnabled && instance._writer)){ - if(callback){ - callback(null, instance); - } - } - }, function(error){ - if(callback){ - callback(error, null); - } - }); - } - - if(writeModeEnabled) { - instance._fileEntry.createWriter(function(fileWriter){ - instance._writer= fileWriter; - - if(truncateFile){ - instance.truncate(0) - } - - if(seekToEnd){ - instance.seek(0, broke.fs.SEEK_END); - } - - if((!readModeEnabled) || (readModeEnabled && instance._file)){ - if(callback){ - callback(null, instance); - } - } - }, function(error){ - if(callback){ - callback(error, null); - } - }); - } - }, function(error){ - if(callback){ - callback(error, null); - } - }); - }); - } - ,read: function(length, callback){ - var - instance= this - ,reader= new FileReader() - ,endpos= ((length === undefined) || (length === null)) ? this._file.size : (this._offset + length) - ,blob= this._slice.call(this._file, this._offset, endpos) - ; - - reader.onload= function(event){ - // The callback is given the three arguments, (err, bytesRead, buffer). - instance._offset+= event.loaded; - - if(callback){ - callback(null, event.loaded, event.target.result); - } - }; - - reader.onerror= function(error){ - if(callback){ - callback(error, 0, null); - } - }; - - reader.onabort= reader.onerror; - - if(this._binaryMode){ - // TO DO -- readAsBinaryString, readAsArrayBuffer or readAsDataURL ? - reader.readAsBinaryString(blob); - } else{ - reader.readAsText(blob); - } - } - ,write: function(buffer, callback){ - var - instance= this - ,builderClass= __global__.BlobBuilder || __global__.WebKitBlobBuilder - ,builderInstance= new builderClass() - ; - - this._writer.onwrite= function(event){ - instance._offset+= event.loaded; - - // The callback will be given three arguments (err, written, buffer) - // where written specifies how many bytes were written into buffer. - if(callback){ - callback(null, event.loaded, buffer); - } - }; - - this._writer.onerror= function(error){ - // The operation may fail after writing some bytes. - // The offset in the file has to be updated according to the bytes written before the error - instance._offset+= error.loaded; - - if(callback){ - callback(error, error.loaded, buffer); - } - }; - - this._writer.onabort= this._writer.onerror; - - builderInstance.append(buffer); - - this._writer.seek(this._offset); - - if(this._binaryMode){ - // TO DO -- MIME Content-Type ? - this._writer.write(builderInstance.getBlob()); - } else{ - this._writer.write(builderInstance.getBlob('text/plain')); - } - } - ,truncate: function(len){ - var - length= ((len !== undefined) && (len !== null)) ? len : this._offset - ; - - if(this._offset > length){ - this._offset= length; - this._writer.seek(length); - } - - this._writer.truncate(length); - } - ,tell: function(){ - return this._offset; - } - ,seek: function(offset, whence){ - if(whence === broke.fs.SEEK_CUR){ - // Relative to current position - this._offset+= offset; - } else if(whence === broke.fs.SEEK_END){ - // Relative to file end - if(this._writer){ - this._offset= this._writer.length + offset; - } else if(this._file){ - this._offset= this._file.size + offset; - } - } else{ - // Absolute indexing - this._offset= offset; - } - - return this; - } - ,rewind: function(){ - this._offset= 0; - } - ,readLine: function(size){} - ,readLines: function(size){} - }); - - Class.create({ - __name__: "broke.fs.Directory" - ,__init__: function(directoryEntry){ - this.directoryEntry= directoryEntry; - } - ,read: function(){} - }); -})(this);/* - * Django template engine based on the porting made by xiaocong.hust and John.Sec.Huang - * http://code.google.com/p/jtl-javascript-template/ - * MIT Licensed - * - */ - -(function(context, undefined){ - broke.template= { - // constants - TOKEN_TEXT: 0, - TOKEN_VAR: 1, - TOKEN_BLOCK: 2, - TOKEN_COMMENT: 3, - - _and: 0, - _or: 1, - - // template syntax constants - FILTER_SEPARATOR: '|', - FILTER_ARGUMENT_SEPARATOR: ':', - VARIABLE_ATTRIBUTE_SEPARATOR: '.', - BLOCK_TAG_START: '{%', - BLOCK_TAG_END: '%}', - VARIABLE_TAG_START: '{{', - VARIABLE_TAG_END: '}}', - COMMENT_BLOCK_TAG_START: '{#', - COMMENT_TAG_END: '#}', - SINGLE_BRACE_START: '{', - SINGLE_BRACE_END: '}', - - tagList: {}, - filterList: {}, - register: { - tag: function(tagName, fn) { - broke.template.tagList[tagName]= fn; - }, - filter: function(filterName, fn) { - broke.template.filterList[filterName]= fn; - } - } - ,getVar: function(context, varstr) { - return builtins.getattr(varstr, context); - } - }; - - Class.create({ - __name__: "broke.template.Template" - ,__init__: function(tpl){ - this._nodelist = this._compile(tpl); - } - ,_compile: function(tpl){ - var tokens, - tagStr= this._formRegx(), - tagRe= new RegExp(tagStr, 'g'), - bits= [], - originalBits= builtins.bsplit(tpl, tagRe); - - builtins.forEach(originalBits, function(){ - if(this != "") { - bits.push(this); - } - }); - - // create token - tokens= builtins.map(bits, function(){ - var tagToken; - - if(builtins.startsWith(this, broke.template.BLOCK_TAG_START)) { - tagToken= this.slice(broke.template.BLOCK_TAG_START.length, -broke.template.BLOCK_TAG_END.length); - return broke.template.Token(broke.template.TOKEN_BLOCK, tagToken); - } - else if(builtins.startsWith(this, broke.template.VARIABLE_TAG_START)) { - return broke.template.Token(broke.template.TOKEN_VAR, this.slice(broke.template.VARIABLE_TAG_START.length, -broke.template.VARIABLE_TAG_END.length)); - } else { - return broke.template.Token(broke.template.TOKEN_TEXT, this); - } - }); - - return (broke.template.Parser(tokens)).parse(); - }, - _formRegx: function(){ - var ret = ''; - - ret += '(' + builtins.rescape(broke.template.BLOCK_TAG_START) + '.*?' + builtins.rescape(broke.template.BLOCK_TAG_END) + - '|' + builtins.rescape(broke.template.VARIABLE_TAG_START) + '.*?' + builtins.rescape(broke.template.VARIABLE_TAG_END) + '|$' + ')'; - - return ret; - }, - render: function(context){ - var result= []; - - builtins.forEach(this._nodelist, function(){ - if(builtins.typeOf(this) == 'object') { - builtins.typeOf(this.render) == 'function' ? - (result.push(this.render(context))) - : - (result.push(this.toString())); - } else { - result.push(this.toString()); - } - }); - - return broke.template.defaultFilters.escape(result.join('')); - } - }); - - broke.template.Template.listRender= function(context, nodelist) { - var result= []; - - builtins.forEach(nodelist, function(){ - result.push(this.render(context)); - }); - - return result.join(''); - }; - - Class.create({ - __parent__: window - ,__name__: "broke.template.Token" - ,__init__: function(type, content){ - this.type= type; - - if(this.type !== broke.template.TOKEN_TEXT) { - // remove trailing and leading white spaces - content= content.replace(/^\s+|\s+$/g, ''); - } - - this.content= content; - }, - tsplit: function(){} - }); -})(this);(function(){ - var - defaultFilters= { - add: function(value){ - return value.asInt() + value.asInt(); - }, - addslashes: function(value){ - return value.replace('\\', '\\\\').replace('"', '\\"').replace("'", "\\'"); - }, - capfirst: function(value){ - return value[0].upper() + value.slice(1).toLowerCase(); - }, - center: function(value, args){ - return center(value, args.asInt()); - }, - cut: function(value, args){ - return value.replace(args, ''); - }, - date: function(value, args){ - if(typeOf(value) != 'date') { - // assume it's a string with format year-month-day - // e.g. 2009-12-31 - value= new Date(value); - } - - return value.format(args); - }, - 'default': function(value, args){ - return value == '' ? args : value; - }, - default_if_null: function(value, args){ - return value === null ? args : value; - }, - dictsort: function(value){ - // TODO - return value; - }, - dictsortreversed: function(value){ - // TODO - return value; - }, - divisibleby: function(value, args){ - return value.asInt() && args.asInt(); - }, - escape: function(value){ - var baseEscapes= [ - ['<', '<'], - ['>', '>'], - ["'", '''], - ['"', '"'], - ['&', '&'] - ]; - builtins.forEach(baseEscapes, function(){ - var bad= this[0], - good= this[1]; - - value.replace(bad, good); - }); - - return value; - }, - escapejs: function(value){ - var baseJsEscapes= [ - ['\\', '\x5C'], - ['\'', '\x27'], - ['"', '\x22'], - ['>', '\x3E'], - ['<', '\x3C'], - ['&', '\x26'], - ['=', '\x3D'], - ['-', '\x2D'], - [';', '\x3B'], - ['\u2028', '\u2028'], - ['\u2029', '\u2029'] - ]; - - builtins.forEach(baseJsEscapes, function(){ - var bad= this[0], - good= this[1]; - - value.replace(bad, good); - }); - - return value; - }, - filesizeformat: function(bytes){ - var KB= 1024, - MB= KB * 1024, - GB= MB * 1024; - - bytes= bytes.asInt(); - - if(bytes < KB) { - return gettext.ngettext("%(size)d byte", "%(size)d bytes", bytes).interpolate({ - size: bytes - }); - } - if(bytes < MB) { - return builtins.interpolate(gettext.gettext('%s KB'), bytes / KB); - } - if(bytes < GB) { - return builtins.interpolate(gettext.gettext('%s MB'), bytes / MB); - } - return builtins.interpolate(gettext.gettext('%s GB'), bytes / GB); - }, - first: function(list){ - return list[0]; - }, - fix_ampersands: function(value){ - return value.replace('&', '&'); - }, - floatformat: function(value, args){ - value= value.split('.'); - args= value[1][args]; - return value[0] + args; - }, - force_escape: function(value){ - return this.escape(value); - }, - get_digit: function(value){ - var start= value * -1, - end= start + 1; - - return value.slice(start, end); - }, - iriencode: function(value){ - // TODO - return value; - }, - join: function(list, args){ - return list.join(args); - }, - last: function(value){ - return value.last(); - }, - length: function(value){ - return value.length; - }, - length_is: function(value, args){ - return value.length == args.asInt(); - }, - linebreaks: function(value){ - // TODO - return value; - }, - linebreaksbr: function(value){ - return value.replace(/\n/g, '
    '); - }, - linenumbers: function(value){ - var numLines, - //maxWidth, - i, - result= []; - - value= value.split('\n'); - numLines= value.length; - //maxWidth= (new String(numLines)).length; - - for(i= 0; i< numLines; i++) { - result.push((i+1) + '. ' + value[i]); - } - - return result.join(''); - }, - ljust: function(value, spaces){ - spaces= spaces.asInt() - value.length; - - if(spaces) { - value= value.split(''); - - while(spaces--) { - value.push(' '); - } - } - - return value.join(''); - }, - lower: function(value){ - return value.toLowerCase(); - }, - make_list: function(value){ - if(typeOf(value) == "number") { - value= new String(value); - - return builtins.map(value.split(''), function(){ - return this.asInt(); - }); - } - - return value.split(''); - }, - phone2numeric: function(value){ - // TODO - return value; - }, - pluralize: function(value, suffix){ - var suffixes= suffix.split(','), - singularSuffix, - pluralSuffix; - - if(suffixes.length > 1) { - singularSuffix= suffixes[0]; - pluralSuffix= suffixes[1]; - } else { - pluralSuffix= suffixes[0]; - singularSuffix= ''; - } - - if(value.length > 1) { - return pluralSuffix; - } - return singularSuffix; - }, - pprint: function(value){ - // TODO - return value; - }, - random: function(list){ - // TODO - return list; - }, - removetags: function(value, tags){ - builtins.forEach(tags.split(' '), function(){ - value.replace('<' + this + '>', '').replace('', ''); - }); - - return value; - }, - rjust: function(value, spaces){ - spaces= spaces.asInt() - value.length; - - if(spaces) { - while(spaces--) { - value += ' '; - } - } - - return value; - }, - safe: function(value){ - // TODO - return value; - }, - safeseq: function(list){ - var _this= this; - - return builtins.map(list, function(){ - return _this.save(this); - }); - }, - slice: function(list, args){ - // slice as in javascript notation, not python notation - // e.g. {{ myList|slice:"0, 3" }} - args= args.split(','); - - if(args.length > 1) { - return list.slice(args[0].asInt(), args[1].asInt()); - } - return list.slice(args[0].asInt()); - }, - slugify: function(value){ - return builtins.slugify(value); - }, - stringformat: function(value, args){ - // TODO - return value; - }, - striptags: function(value){ - return value.replace(/<[a-zA-Z_]>/g, '').replace(/<\/[a-zA-Z_]>/g, ''); - }, - time: function(value){ - // TODO - return value; - }, - timesince: function(value){ - // TODO - return value; - }, - timeuntil: function(value){ - // TODO - return value; - }, - title: function(value){ - // TODO - return value.capitalize(); - }, - truncatewords: function(value, numberOfWords){ - return value.split(' ').slice(0, numberOfWords).join('') + '...'; - }, - truncatewords_html: function(value){ - // TODO - return value; - }, - unordered_list: function(list){ - var createUl= function(list){ - var newUl= []; - - builtins.forEach(list, function(){ - if(typeOf(this) == "array") { - newUl.push('
      '); - newUl.push(createUl(this)); - newUl.push('
    '); - } - newUl.push('
  • '); - newUl.push(this); - newUl.push('
  • '); - }); - - return newUl.join(''); - }; - - return createUl(list); - }, - upper: function(value){ - return value.upper(); - }, - urlencode: function(value){ - // TODO - return value; - }, - urlize: function(value){ - // TODO - return value; - }, - urlizetrunc: function(value){ - // TODO - return value; - }, - wordcount: function(value){ - return value.split(' ').length; - }, - wordwrap: function(value, args){ - // TODO - return value; - }, - yesno: function(value, args){ - args= args.split(','); - - var yes= args[0], - no= args[1], - maybe= args[2] || no; - - if(value === null) { - return maybe; - } else if(value) { - return yes; - } - - return no; - } - } - ; - - broke.extend(broke.template, { - defaultFilters: defaultFilters - }); - - // register the default filters - broke.extend(broke.template, { - filterList: defaultFilters - }); -})();(function(){ - var - tpl= broke.template, - register= tpl.register, - TemplateSyntaxError= broke.exceptions.TemplateSyntaxError - ; - - register.tag('if', function(parser, token){ - var - bits = token.content.split(/\s+/) - ,linkType - ,nodeListTrue - ,nodeListFalse - ,bitstr - ,boolPairs - ; - - bits.shift(); - - if(!bits){ - throw TemplateSyntaxError(gettext.gettext('If node need at least one args')); - } - - bitstr= bits.join(' '); - - boolPairs= bitstr.split(' or '); - - if(boolPairs.length == 1){ - linkType = tpl.IfNode._and; - boolPairs = bitstr.split(' and '); - } else { - linkType = tpl.IfNode._or; - - if(bitstr.indexOf(' and ') != -1) { - throw TemplateSyntaxError(gettext.gettext('If node do not allow mix "and" & "or"')); - } - } - - nodeListTrue = parser.parse(['else','endif']); - token= parser.nextToken(); - - if(token.content.indexOf('else') != -1){ - nodeListFalse = parser.parse('endif'); - parser.deleteFirstToken(); - } else { - nodeListFalse = []; - } - return new tpl.IfNode(linkType, boolPairs, nodeListTrue, nodeListFalse); - }); - - register.tag('ifequal', function(parser, token){ - var - bits = token.content.split(/\s+/) - ,nodeListTrue - ,nodeListFalse - ,bitstr - ,boolPairs - ; - - bits.shift(); - - if(bits.length < 2){ - throw TemplateSyntaxError(gettext.gettext('Ifequal node need at least two args')); - } - - nodeListTrue = parser.parse(['else','endifequal']); - token= parser.nextToken(); - - if(token.content.indexOf('else') != -1){ - nodeListFalse = parser.parse('endifequal'); - parser.deleteFirstToken(); - } else { - nodeListFalse = []; - } - - return new tpl.IfEqualNode(bits, nodeListTrue, nodeListFalse); - }); - - register.tag('comment', function(parser, token){ - parser.skipPast('endcomment'); - return new tpl.CommentNode(); - }); - - register.tag('for', function(parser, token) { - var - bits = token.content.split(/\s+/), - loopvar= bits[1], - sequence= bits[3], - reversed= (bits.length == 5), - nodeListLoop= parser.parse('endfor') - ; - - if(bits.length == 5 && bits[4] != 'reversed'){ - throw TemplateSyntaxError(gettext.gettext('The 4 args of for tag must be reversed')); - } - if(!builtins.has([4, 5], bits.length)) { - throw TemplateSyntaxError(gettext.gettext('The for tag should have 4 or 5 args')); - } - if(bits[2] != 'in'){ - throw TemplateSyntaxError(gettext.gettext('The 2nd args of for tag must be "in"')); - } - - parser.deleteFirstToken(); - return new tpl.ForNode(loopvar,sequence,reversed,nodeListLoop); - }); - - register.tag('url', function(parser, token) { - var - bits = token.content.split(/\s+/) - ,viewName= bits[1] - ,args= bits[2].split(',') - ,asVar - ; - - if(bits.length == 5){ - if(bits[3] != 'as') { - throw TemplateSyntaxError(gettext.gettext('The 3 args of for tag must be "as"')); - } - asVar= bits[3]; - } - - return new tpl.UrlNode(viewName, args, asVar); - }); -})();(function(context, undefined){ - var Template= broke.template.Template; - - broke.extend(broke.template, { - loader: { - renderToString: function(templateName, context){ - var i, - loader, - template; - - for(i= 0; i< broke.conf.settings.TEMPLATE_LOADERS.length; i++) { - loader= broke.conf.settings.TEMPLATE_LOADERS[i]; - - if(builtins.typeOf(loader) == "string") { - loader= builtins.getattr(loader); - } - - if((template= loader.loadTemplate(templateName))) { - break; - } - }; - - if(template) { - return Template(template).render(context); - } - - // no template found - return ''; - } - } - }); -})(this);(function(context, undefined){ - var - templatesCache= {} - ,settings= broke.conf.settings - ; - - broke.extend(broke.template, { - loaders: { - apps: { - loadTemplate: function(templateName){ - var template, - len= settings.INSTALLED_APPS.length, - result, - app; - - // loops through all the apps - while(len--) { - app= settings.INSTALLED_APPS[len]; - - if(app) { - // check if the template exists inside this project's templates - if(app.templates !== undefined && templateName in app.templates) { - return app.templates[templateName]; - } - } - } - - // no template found - return template; - } - } - ,remote: { - loadTemplate: function(templateName){ - var template, - url, - templatePath, - len= settings.TEMPLATE_PATHS.length; - - // not sure about that... - while(len--) { - templatePath= settings.TEMPLATE_PATHS; - - url= templatePath + '/' + templateName; - - if(url in templatesCache) { - return templatesCache[url]; - } - - $.ajax({ - async: false, - url: url, - success: function(responseText){ - template= responseText; - - // cache the response - templatesCache[url]= template; - }, - error: function(error){ - // TODO - } - }); - } - - return template; - } - } - } - }); -})(this);(function(){ - var - tpl= broke.template - ,Template= tpl.Template - ,TemplateSyntaxError= broke.exceptions.TemplateSyntaxError - ,settings= broke.conf.settings - ; - - Class.create({ - __name__: "broke.template.VarNode" - ,__init__: function(varstr){ - var - args= varstr.split(tpl.FILTER_SEPARATOR) - ; - - this.varstr= args[0]; - this.filters= args.slice(1); - this.content= null; - } - ,applyFilters: function(){ - var - _this= this - ; - - builtins.forEach(this.filters, function(){ - // split arguments to pass to the filter, if any - var args= this.split(tpl.FILTER_ARGUMENT_SEPARATOR)[1] || null; - - if(!(this in tpl.filterList)) { - // filter not found, fail silently... - broke.log('Filter not found, fail silently...'); - return; - } - - _this.content= tpl.filterList[this](_this.content, args); - }); - - return this; - } - ,render: function(context){ - var - content= builtins.getattr(this.varstr, context, "") - ; - - if(builtins.typeOf(content) == "function") { - content= content(); - } - - this.content= content; - - if(this.filters) { - this.applyFilters(); - } - - return this.content; - } - }); - - Class.create({ - __name__: "broke.template.TextNode" - ,__init__: function(str){ - this.str= str; - } - ,render: function(){ - return this.str; - } - }); - - Class.create({ - __name__: "broke.template.CommentNode" - ,__init__: function(str){ - this.str= str; - } - ,render: function(context){ - return ''; - } - }); - - Class.create({ - __name__: "broke.template.IfNode" - ,__init__: function(linkType, boolPairs, nodeListTrue, nodeListFalse){ - this.linkType = linkType; - this.boolPairs = boolPairs; - this.nodeListTrue = nodeListTrue; - this.nodeListFalse = nodeListFalse; - } - ,render: function(context){ - var - flag - ; - - if(this.linkType == tpl._and) { - flag = true; - - if(this.mapBoolpair(false, context)) { - flag=false; - } - } else { - flag = false; - - if(this.mapBoolpair(true, context)) { - flag=true; - } - } - - return flag ? Template.listRender(context, this.nodeListTrue) : Template.listRender(context, this.nodeListFalse); - } - ,mapBoolpair: function(tc, context){ - var - tmpbp = '' - ,bp = this.boolPairs - ,i - ,ilen - ; - - for(i= 0, ilen= bp.length; i< ilen; i++) { - tmpbp = bp[i].split(' '); - - if(tmpbp.length== 2 && tmpbp[0] == 'not') { - //if(tc != !!tpl.getVar(context, tmpbp[1])) { - if(tc != tpl.getVar(context, tmpbp[1])) { - return true; - } - } else { - //if(tc == !!tpl.getVar(context, tmpbp[0])) { - if(tc == tpl.getVar(context, tmpbp[0])) { - return true; - } - } - } - return false; - } - }); - - Class.create({ - __name__: "broke.template.IfEqualNode" - ,__init__: function(vars, nodeListTrue, nodeListFalse){ - this.vars= vars; - this.nodeListTrue = nodeListTrue; - this.nodeListFalse = nodeListFalse; - } - ,render: function(context){ - var - flag= true - ,len= this.vars.length - 1 - ,currentVar - ,previousVar= tpl.getVar(context, this.vars.slice(-1)[0]) - ; - - while(len--) { - currentVar= tpl.getVar(context, this.vars[len]); - - if(previousVar != currentVar) { - flag= false; - } - - previousVar= currentVar; - } - - return flag ? Template.listRender(context, this.nodeListTrue) : Template.listRender(context, this.nodeListFalse); - } - }); - - Class.create({ - __name__: "broke.template.ForNode" - ,__init__: function(loopvar, sequence, reversed, nodeListLoop){ - this.loopvar= loopvar; - this.sequence= sequence.split('.'); - this.reversed= reversed; - this.nodeListLoop= nodeListLoop; - } - ,render: function(context){ - var - ret = [] - ,parentloop - ,items = context - ,k - ,i - ,klen - ,ilen - ; - - if(context.forloop) { - parentloop= context.forloop; - } - for(k= 0, klen= this.sequence.length; k< klen; k++) { - items= items[this.sequence[k]]; - } - - if(!(items instanceof Array)){ - throw TemplateSyntaxError(gettext.gettext('values is not a array')); - } - - if(this.reversed){ - items = items.reverse(); - } - - for(i= 0, ilen= items.length; i< ilen; i++){ - context.forloop= { - //shortcuts for current loop iteration number - 'counter0': i, - 'counter': i + 1, - //reverse counter iteration numbers - 'revcounter': ilen - i, - 'revcounter0': ilen - i - 1, - //boolean values designating first and last times through loop - 'first': (i == 0), - 'last': (i == (ilen - 1)), - 'parentloop': parentloop - }; - - context[this.loopvar] = items[i]; - ret.push(Template.listRender(context, this.nodeListLoop)); - } - - context.forloop = undefined; - return ret.join(''); - } - }); - - Class.create({ - __name__: "broke.template.UrlNode" - ,__init__: function(viewName, args, asVar){ - this.viewName= viewName; - this.args= args; - this.asVar= asVar; - } - ,render: function(context){ - var - reverse= broke.urlResolvers.reverse - ,args= [] - ,projectName - ; - - builtins.forEach(this.args, function(){ - var thisVar= builtins.getattr(this, context); - - if(thisVar === undefined) { - thisVar= this.asInt(); - - if(typeOf(thisVar) == "NaN") { - thisVar = this; - } - } - - args.push(thisVar); - }); - - try { - // named url ? - url= reverse(this.viewName, args); - - } catch(e){ - if(e.name == "NoReverseMatch") { - // nope, then it's a path to a view - - projectName= settings.SETTINGS_MODULE.split('.')[0]; - url= reverse(projectName + this.viewName, args); - } - } - - if(this.asVar) { - context[this.asVar]= url; - return '' - } - return url; - } - }); -})();(function(){ - var - tpl= broke.template - ,TemplateSyntaxError= broke.exceptions.TemplateSyntaxError - ; - - Class.create({ - __parent__: window - ,__name__: "broke.template.Parser" - ,__init__: function(tokens){ - this.tokens= tokens; - }, - parse: function(parseUntil){ - var - nodelist = [] - ,token = null - ,tagFuncName = null - ,tagFunc = null - ; - - if(!parseUntil) { - parseUntil = []; - } - if(!(parseUntil instanceof Array)) { - parseUntil= [parseUntil]; - } - - while(this.tokens.length){ - token= this.tokens.shift(); - - if(token.type == tpl.TOKEN_TEXT){ - nodelist.push(new tpl.TextNode(token.content)); - } - else if(token.type == tpl.TOKEN_VAR){ - nodelist.push(new tpl.VarNode(token.content)); - } - else if(token.type == tpl.TOKEN_BLOCK) { - if(builtins.has(parseUntil, token.content)) { - this.prependToken(token); - return nodelist; - } - - tagFuncName= token.content.split(/\s+/)[0]; - - if(!tagFuncName) { - throw TemplateSyntaxError(gettext.gettext('Empty Tag')); - } - tagFunc = tpl.tagList[tagFuncName]; - - if(!tagFunc) { - throw TemplateSyntaxError(gettext.gettext('Unknow Tag')); - } - nodelist.push(tagFunc(this,token)); - } - } - return nodelist; - }, - skipPast: function(endtag){ - var - token = null - ; - - while(this.tokens.length){ - token = this.tokens.shift(); - - if(token.type == tpl.TOKEN_BLOCK && token.content == endtag){ - return; - } - } - throw TemplateSyntaxError(gettext.gettext('Not Closed Tag')); - }, - prependToken: function(token){ - this.tokens.unshift(token); - }, - nextToken: function(){ - return this.tokens.shift(); - }, - deleteFirstToken: function(){ - this.tokens.shift(); - return true; - } - }); -})();;(function(undefined){ - - broke.extend(broke.utils, { - functional: { - lazy: function(fn, context){ - // a much simpler version of the lazy function loader - // which works with strings only - - // a context needs to be supplied in order to execute the - // function in the right context - // defaults to the window object - context= context || window; - - return function(){ - var args= Array.prototype.slice.call(arguments); - - // returns an object which override the toString method - // to return whatever function has been supplied - // within the right context, given the supplied the arguments - return { - toString: function(){ - return fn.apply(context, args); - } - }; - }; - } - } - }); - -})();;(function(undefined){ - - broke.extend(broke.utils, { - translation: { - getLanguageFiles: function(){ - var - settings= broke.conf.settings - ,languageCode= settings.LANGUAGE_CODE - ,localePath= builtins.interpolate('/locale/%s/LC_MESSAGES/broke.po', languageCode) - ,localePaths= [ - settings.BASE_URL + '/conf' - ] - ; - - // projects' locale paths - localePaths.populate(settings.LOCALE_PATHS); - - builtins.forEach(localePaths, function(){ - gettext.init({ - url: this + localePath - }); - }); - - return; - } - ,setLanguage: function(){ - // 1. look in the url - var queryString= broke.urlResolvers.parseQueryString(location.href.split('?')[1]), - cookie= $.cookie(settings.LANGUAGE_COOKIE_NAME), - langCodeFromCookie; - - // check query string - if('language' in queryString) { - settings.LANGUAGE_CODE= queryString.language; - - // set cookie language - $.cookie(settings.LANGUAGE_COOKIE_NAME, queryString.language, { - expires: 30, - domain: location.host, - path: '/' - }); - } else { - // 2. check cookie - langCodeFromCookie= $.cookie(settings.LANGUAGE_COOKIE_NAME); - - settings.LANGUAGE_CODE= langCodeFromCookie || settings.LANGUAGE_CODE; - } - } - ,gettext: function(){} - } - }); - -})();;(function(context, undefined){ - broke.views= { - defaults: { - setLanguage: function(request){ - var next= request.REQUEST['next'] || null, - response= {}, - settings= broke.conf.settings, - langCode, - checkForLanguage; - - if(!next) { - next= request.META['HTTP_REFERER']; - } - if(!next) { - next= ''; - } - - langCode= request.REQUEST['language'] || null; - - // if(langCode && checkForLanguage(langCode)) { - if(true) { - if('session' in request) { - // still not sure how to handle this - // TODO - request.session.brokeLanguage= langCode; - } else if('cookie' in request) { - // still not sure how to handle this - // TODO - //request.cookie= [settings.LANGUAGE_COOKIE_NAME, langCode]; - } else { - location.href= location.href.split('#')[0].split('?')[0] + '?language=' + langCode; - } - } - - //broke.events.request(next); - return {}; - }, - pageNotFound: function(request){ - // no matching url found, fail silently... - broke.log(gettext.gettext("No matching url found, fail silently...")); - } - } - }; -})(this);;(function(context, undefined){ - var - settings= broke.conf.settings - ,applyContextProcessors= function(response){ - builtins.forEach(settings.CONTEXT_PROCESSORS, function(){ - var contextProcessor= builtins.getattr(this); - - broke.extend(response.context, contextProcessor(response)); - }); - - return response.context; - } - ; - - broke.shortcuts= { - node: { - create: function(response){ - /* response= { - * template: compulsory template - * context: template's context - * method: after|before|append|prepend|wrap. it defaults to 'append' - * htmlNode: node or string to search the node, - * to which append the newly created node. - * it defaults to 'body' - * emptyHtmlNodeFirst: whether or not to empty the htmlNode - * additionalProperties: additional properties to append to the - * newly created htmlNode - * callback: a function that gets applied to the newly created htmlNode - * } - * - */ - var - allowedMethods= ['after', 'before', 'append', 'prepend', 'wrap'] - ,context= applyContextProcessors(response) - ,renderedTemplate= broke.template.loader.renderToString(response.template, context) - ,newElement= broke.DOM.m.createFromString(renderedTemplate) - ; - - // default arguments - response= broke.extend({ - method: 'append' - ,htmlNode: 'body' - ,emptyHtmlNodeFirst: false - }, response); - - if(!builtins.has(allowedMethods, response.method)) { - throw broke.exceptions.NotImplementedError(builtins.interpolate(gettext.gettext("The selected template's method (%s) is not implemented. Options are: after, before, append, prepend, wrap"), response.method)); - } - - if(response.emptyHtmlNodeFirst) { - broke.DOM.html(response.htmlNode, ''); - } - - // append support only, for now - broke.DOM.m.append(newElement, response.htmlNode); - - response.element= newElement; - - if(settings.EVENT_TRIGGERING_METHOD == 'elements') { - broke.bindEvents(newElement); - } - - return response; - } - ,replace: function(response){ - /* - * Renders the template and then replace the element with the - * rendered template - * response= { - * template: compulsory template - * context: template's context - * htmlNode: node or string to search the node, - * with which replace the newly created node - * additionalProperties: additional properties to append to the - * newly created htmlNode - * callback: a function that gets applied to the newly created htmlNode - * } - * - */ - var - context= applyContextProcessors(response) - ,renderedTemplate= broke.template.loader.renderToString(response.template, context) - ,newElement= broke.DOM.m.createFromString(renderedTemplate) - ; - - // replace - broke.DOM.m.replace(response.htmlNode, newElement); - - response.element= newElement; - - if(settings.EVENT_TRIGGERING_METHOD == 'elements') { - broke.bindEvents(newElement); - } - - return response; - } - ,update: function(response){ - /* - response= { - * object: object with which update the html node - * htmlNode: node or string to search the node to update - * attribute: rel|class - * childrenOnly: whether you want to search direct descendant only - * for optimizations purpose or all the descendants - * additionalProperties: additional properties to append to the - * every single updated node - * callback: a function that gets applied to the newly created htmlNode - * } - * - * This method expect the html node to have children with - * the rel or class attribute corresponding to fields of the object - * - * i.e. - * object's fields: { - * title: 'New title', - * description: 'New description', - * } - * html node: - *
      - *
    • My title
    • - *
    • My description
    • - *
    - * - * would become: - * - * html node:
      - *
    • New title
    • - *
    • New description
    • - *
    - * - * WARNING: quite resource heavy on big html nodes - * TODO: optimize - * - */ - var - acceptedAttributes= ['class', 'rel'] - ,searchFor - ; - - // default arguments - response= broke.extend({ - attribute: 'rel', - childrenOnly: true - }, response); - - searchFor= response.childrenOnly ? '> *' : '*'; - - if(!builtins.has(acceptedAttributes, response.attribute)) { - throw broke.exceptions.NotImplementedError(builtins.interpolate(gettext.gettext("You can not use %s's attribute. Options are: class, rel"), response.attribute)); - } - - builtins.forEach(broke.DOM.querySelector(searchFor, response.htmlNode), function(){ - var - attr= broke.DOM.attr - ,key - ; - - for(key in response.object.fields) { - - if(response.object.fields.hasOwnProperty(key) && attr(this, response.attribute) !== undefined) { - - if(attr(this, response.attribute).contains(key)) { - // update the node - broke.DOM.html(this, response.object.fields[key]); - } - } - } - }); - - response.element= response.htmlNode; - - return true; - } - } - }; -})(this); \ No newline at end of file diff --git a/labs/architecture-examples/broke/libs/gettext.min.js b/labs/architecture-examples/broke/libs/gettext.min.js deleted file mode 100644 index 01e5d0c69d..0000000000 --- a/labs/architecture-examples/broke/libs/gettext.min.js +++ /dev/null @@ -1,54 +0,0 @@ - -(function(__global__){var -contextGlue="\004",_localeData={},domain='messages',localeData,url='',tryLoadLang=function(){var localeCopy,langLink,i,link;if(typeof(localeData)!='undefined'){localeCopy=localeData;localeData=undefined;parseLocaleData(localeCopy);if(typeof(_localeData[domain])=='undefined'){throw new Error("Error: Gettext 'localeData' does not contain the domain '"+domain+"'");}} -langLink=getLangRefs();if(typeof(langLink)=='object'&&langLink.length>0){for(i=0;i+*/%:;a-zA-Z0-9_\(\)])+)",'m');if(pf_re.test(plural_forms)){pf=_localeData[domain].head['plural-forms'];if(!/;\s*$/.test(pf)){pf=pf.concat(';');} -code='var plural; var nplurals; '+pf+' return { "nplural" : nplurals, "plural" : (plural === true ? 1 : plural ? plural : 0) };';_localeData[domain].head.plural_func=new Function("n",code);}else{throw new Error("Syntax error in language file. Plural-Forms header is invalid ["+plural_forms+"]");}}else if(typeof(_localeData[domain].head.plural_func)=='undefined'){_localeData[domain].head.plural_func=function(n){p=(n!=1)?1:0;return{'nplural':2,'plural':p};};}} -return;},tryLoadLangPo=function(uri){var data=getFile(uri),domain,parsed,rv;if(!data){return;} -domain=uriBasename(uri);parsed=parsePo(data);rv={};if(parsed){if(!parsed[""]){parsed[""]={};} -if(!parsed[""].domain){parsed[""].domain=domain;} -domain=parsed[""].domain;rv[domain]=parsed;parseLocaleData(rv);} -return 1;},parsePo=function(data){var rv={},buffer={},lastbuffer="",errors=[],lines=data.split("\n"),i,match,msg_ctxt_id,msgid_plural,trans,str,cur,hlines,pos,key,val,keylow;for(i=0;i1){rv[msg_ctxt_id]=trans;} -buffer={};lastbuffer="";}}else if(/^#/.test(lines[i])){continue;}else if((match=lines[i].match(/^msgctxt\s+(.*)/))){lastbuffer='msgctxt';buffer[lastbuffer]=parsePoDequote(match[1]);}else if((match=lines[i].match(/^msgid\s+(.*)/))){lastbuffer='msgid';buffer[lastbuffer]=parsePoDequote(match[1]);}else if((match=lines[i].match(/^msgid_plural\s+(.*)/))){lastbuffer='msgid_plural';buffer[lastbuffer]=parsePoDequote(match[1]);}else if((match=lines[i].match(/^msgstr\s+(.*)/))){lastbuffer='msgstr_0';buffer[lastbuffer]=parsePoDequote(match[1]);}else if((match=lines[i].match(/^msgstr\[0\]\s+(.*)/))){lastbuffer='msgstr_0';buffer[lastbuffer]=parsePoDequote(match[1]);}else if((match=lines[i].match(/^msgstr\[(\d+)\]\s+(.*)/))){lastbuffer='msgstr_'+match[1];buffer[lastbuffer]=parsePoDequote(match[2]);}else if(/^"/.test(lines[i])){buffer[lastbuffer]+=parsePoDequote(lines[i]);}else{errors.push("Strange line ["+i+"] : "+lines[i]);}} -if(typeof(buffer.msgid)!='undefined'){msg_ctxt_id=(typeof(buffer.msgctxt)!='undefined'&&buffer.msgctxt.length)?buffer.msgctxt+contextGlue+buffer.msgid:buffer.msgid;msgid_plural=(typeof(buffer.msgid_plural)!='undefined'&&buffer.msgid_plural.length)?buffer.msgid_plural:null;trans=[];for(str in buffer){if((match=str.match(/^msgstr_(\d+)/))){trans[parseInt(match[1],10)]=buffer[str];}} -trans.unshift(msgid_plural);if(trans.length>1){rv[msg_ctxt_id]=trans;} -buffer={};lastbuffer="";} -if(rv[""]&&rv[""][1]){cur={};hlines=rv[""][1].split(/\\n/);for(i=0;i0&&args[arg_n-1]!=null&&typeof(args[arg_n-1])!='undefined'){newstr+=args[arg_n-1];} -str=str.substr((i+1+length_n));}else{newstr+='%';str=str.substr((i+1));}} -return newstr;},isArray=function(thisObject){return isValidObject(thisObject)&&thisObject.constructor==Array;},isValidObject=function(thisObject){if(null==thisObject){return false;}else if('undefined'==typeof(thisObject)){return false;}else{return true;}},getFile=function(path){var -fs;try{fs=require('fs');return fs.openSync(path,'r');}catch(e){return sjax(path);}},sjax=function(uri){var xmlhttp;if(window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}else if(navigator.userAgent.toLowerCase().indexOf('msie 5')!=-1){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}else{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");} -if(!xmlhttp){throw new Error("Your browser doesn't support Ajax. Unable to support external language files.");} -xmlhttp.open('GET',uri,false);try{xmlhttp.send(null);}catch(e){return;} -var sjax_status=xmlhttp.status;if(sjax_status==200||sjax_status==0){return xmlhttp.responseText;}else{var error=xmlhttp.statusText+" (Error "+xmlhttp.status+")";if(xmlhttp.responseText.length){error+="\n"+xmlhttp.responseText;} -return;}},JSON=function(data){return eval('('+data+')');};__global__.gettext={dcnpgettext:dcnpgettext,dnpgettext:dnpgettext,npgettext:npgettext,dcpgettext:dcpgettext,dpgettext:dpgettext,pgettext:pgettext,dcngettext:dcngettext,dngettext:dngettext,ngettext:ngettext,dcgettext:dcgettext,dgettext:dgettext,gettext:gettext,textdomain:textdomain,parsePo:parsePo,tryLoadLangPo:tryLoadLangPo,tryLoadLang:tryLoadLang};})(this); \ No newline at end of file diff --git a/labs/architecture-examples/broke/libs/jquery-1.6.4.min.js b/labs/architecture-examples/broke/libs/jquery-1.6.4.min.js deleted file mode 100644 index fd2a159613..0000000000 --- a/labs/architecture-examples/broke/libs/jquery-1.6.4.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! jQuery v1.6.4 http://jquery.com/ | http://jquery.org/license */ -(function(a,b){function cu(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cr(a){if(!cg[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ch||(ch=c.createElement("iframe"),ch.frameBorder=ch.width=ch.height=0),b.appendChild(ch);if(!ci||!ch.createElement)ci=(ch.contentWindow||ch.contentDocument).document,ci.write((c.compatMode==="CSS1Compat"?"":"")+""),ci.close();d=ci.createElement(a),ci.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ch)}cg[a]=e}return cg[a]}function cq(a,b){var c={};f.each(cm.concat.apply([],cm.slice(0,b)),function(){c[this]=a});return c}function cp(){cn=b}function co(){setTimeout(cp,0);return cn=f.now()}function cf(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ce(){try{return new a.XMLHttpRequest}catch(b){}}function b$(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;g0){c!=="border"&&f.each(e,function(){c||(d-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?d+=parseFloat(f.css(a,c+this))||0:d-=parseFloat(f.css(a,"border"+this+"Width"))||0});return d+"px"}d=bv(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0,c&&f.each(e,function(){d+=parseFloat(f.css(a,"padding"+this))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+this+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+this))||0)});return d+"px"}function bl(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bd,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bk(a){f.nodeName(a,"input")?bj(a):"getElementsByTagName"in a&&f.grep(a.getElementsByTagName("input"),bj)}function bj(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bi(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bh(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 bg(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=0===c})}function U(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function M(a,b){return(a&&a!=="*"?a+".":"")+b.replace(y,"`").replace(z,"&")}function L(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;ic)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 J(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 D(){return!0}function C(){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").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 K(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(K,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=/-([a-z]|[0-9])/ig,x=/^-ms-/,y=function(a,b){return(b+"").toUpperCase()},z=d.userAgent,A,B,C,D=Object.prototype.toString,E=Object.prototype.hasOwnProperty,F=Array.prototype.push,G=Array.prototype.slice,H=String.prototype.trim,I=Array.prototype.indexOf,J={};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.4",length:0,size:function(){return this.length},toArray:function(){return G.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)?F.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(),B.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(G.apply(this,arguments),"slice",G.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:F,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(;j0)return;B.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!B){B=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",C,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",C),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&K()}}},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):J[D.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!E.call(a,"constructor")&&!E.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||E.call(a,d)},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(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(x,"ms-").replace(w,y)},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(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?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
    a",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=a.getElementsByTagName("input")[0],k={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:i.value==="on",optSelected:h.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,k.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,k.optDisabled=!h.disabled;try{delete a.test}catch(v){k.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function(){k.noCloneEvent=!1}),a.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),k.radioValue=i.value==="t",i.setAttribute("checked","checked"),a.appendChild(i),l=c.createDocumentFragment(),l.appendChild(a.firstChild),k.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",m=c.getElementsByTagName("body")[0],o=c.createElement(m?"div":"body"),p={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},m&&f.extend(p,{position:"absolute",left:"-1000px",top:"-1000px"});for(t in p)o.style[t]=p[t];o.appendChild(a),n=m||b,n.insertBefore(o,n.firstChild),k.appendChecked=i.checked,k.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,k.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
    ",k.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
    t
    ",q=a.getElementsByTagName("td"),u=q[0].offsetHeight===0,q[0].style.display="",q[1].style.display="none",k.reliableHiddenOffsets=u&&q[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",a.appendChild(j),k.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0),o.innerHTML="",n.removeChild(o);if(a.attachEvent)for(t in{submit:1,change:1,focusin:1})s="on"+t,u=s in a,u||(a.setAttribute(s,"return;"),u=typeof a[s]=="function"),k[t+"Bubbles"]=u;o=l=g=h=m=j=a=i=null;return k}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([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,h,i=f.expando,j=typeof c=="string",k=a.nodeType,l=k?f.cache:a,m=k?a[f.expando]:a[f.expando]&&f.expando;if((!m||e&&m&&l[m]&&!l[m][i])&&j&&d===b)return;m||(k?a[f.expando]=m=++f.uuid:m=f.expando),l[m]||(l[m]={},k||(l[m].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?l[m][i]=f.extend(l[m][i],c):l[m]=f.extend(l[m],c);g=l[m],e&&(g[i]||(g[i]={}),g=g[i]),d!==b&&(g[f.camelCase(c)]=d);if(c==="events"&&!g[c])return g[i]&&g[i].events;j?(h=g[c],h==null&&(h=g[f.camelCase(c)])):h=g;return h}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e=f.expando,g=a.nodeType,h=g?f.cache:a,i=g?a[f.expando]:f.expando;if(!h[i])return;if(b){d=c?h[i][e]:h[i];if(d){d[b]||(b=f.camelCase(b)),delete d[b];if(!l(d))return}}if(c){delete h[i][e];if(!l(h[i]))return}var j=h[i][e];f.support.deleteExpando||!h.setInterval?delete h[i]:h[i]=null,j?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=j):g&&(f.support.deleteExpando?delete a[f.expando]:a.removeAttribute?a.removeAttribute(f.expando):a[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-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;d=e.value;return typeof d=="string"?d.replace(p,""):d==null?"":d}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,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c=a.selectedIndex,d=[],e=a.options,g=a.type==="select-one";if(c<0)return null;for(var h=g?c:0,i=g?c+1:e.length;h=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);var h,i,j=g!==1||!f.isXMLDoc(a);j&&(c=f.attrFix[c]||c,i=f.attrHooks[c],i||(t.test(c)?i=v:u&&(i=u)));if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j&&(h=i.get(a,c))!==null)return h;h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){var c;a.nodeType===1&&(b=f.attrFix[b]||b,f.attr(a,b,""),a.removeAttribute(b),t.test(b)&&(c=f.propFix[b]||b)in a&&(a[c]=!1))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},value:{get:function(a,b){if(u&&f.nodeName(a,"button"))return u.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(u&&f.nodeName(a,"button"))return u.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);i&&(c=f.propFix[c]||c,h=f.propHooks[c]);return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==null?g:a[c]},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}}}}),f.attrHooks.tabIndex=f.propHooks.tabIndex,v={get:function(a,c){var d;return f.prop(a,c)===!0||(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},f.support.getSetAttribute||(u=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&d.nodeValue!==""?d.nodeValue:b},set:function(a,b,d){var e=a.getAttributeNode(d);e||(e=c.createAttribute(d),a.setAttributeNode(e));return e.nodeValue=b+""}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex);return null}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var w=/\.(.*)$/,x=/^(?:textarea|input|select)$/i,y=/\./g,z=/ /g,A=/[^\w\s.|`]/g,B=function(a){return a.replace(A,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=C;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=C);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),B).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d!=null?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},I=function(c){var d=c.target,e,g;if(!!x.test(d.nodeName)&&!d.readOnly){e=f._data(d,"_change_data"),g=H(d),(c.type!=="focusout"||d.type!=="radio")&&f._data(d,"_change_data",g);if(e===b||g===e)return;if(e!=null||g)c.type="change",c.liveFired=b,f.event.trigger(c,arguments[1],d)}};f.event.special.change={filters:{focusout:I,beforedeactivate:I,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&I.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&I.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",H(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in G)f.event.add(this,c+".specialChange",G[c]);return x.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return x.test(this.nodeName)}},G=f.event.special.change.filters,G.focus=G.beforeactivate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

    ";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
    ";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g0)for(h=g;h0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=S.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(U(c[0])||U(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=R.call(arguments);N.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!T[a]?f.unique(e):e,(this.length>1||P.test(d))&&O.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
    ","
    "],thead:[1,"","
    "],tr:[2,"","
    "],td:[3,"","
    "],col:[2,"","
    "],area:[1,"",""],_default:[0,"",""]};be.optgroup=be.option,be.tbody=be.tfoot=be.colgroup=be.caption=be.thead,be.th=be.td,f.support.htmlSerialize||(be._default=[1,"div
    ","
    "]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!be[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bh(a,d),e=bi(a),g=bi(d);for(h=0;e[h];++h)g[h]&&bh(e[h],g[h])}if(b){bg(a,d);if(c){e=bi(a),g=bi(d);for(h=0;e[h];++h)bg(e[h],g[h])}}e=g=null;return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=be[l]||be._default,n=m[0],o=b.createElement("div");o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bn.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bm,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bm.test(g)?g.replace(bm,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bv(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bw=function(a,c){var d,e,g;c=c.replace(bo,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bx=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bp.test(d)&&bq.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bv=bw||bx,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bz=/%20/g,bA=/\[\]$/,bB=/\r?\n/g,bC=/#.*$/,bD=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bE=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bF=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bG=/^(?:GET|HEAD)$/,bH=/^\/\//,bI=/\?/,bJ=/)<[^<]*)*<\/script>/gi,bK=/^(?:select|textarea)/i,bL=/\s+/,bM=/([?&])_=[^&]*/,bN=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bO=f.fn.load,bP={},bQ={},bR,bS,bT=["*/"]+["*"];try{bR=e.href}catch(bU){bR=c.createElement("a"),bR.href="",bR=bR.href}bS=bN.exec(bR.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bO)return bO.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
    ").append(c.replace(bJ,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bK.test(this.nodeName)||bE.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bB,"\r\n")}}):{name:b.name,value:c.replace(bB,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?bX(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),bX(a,b);return a},ajaxSettings:{url:bR,isLocal:bF.test(bS[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bT},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bV(bP),ajaxTransport:bV(bQ),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?bZ(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=b$(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bD.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bC,"").replace(bH,bS[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bL),d.crossDomain==null&&(r=bN.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bS[1]&&r[2]==bS[2]&&(r[3]||(r[1]==="http:"?80:443))==(bS[3]||(bS[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bW(bP,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bG.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bI.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bM,"$1_="+x);d.url=y+(y===d.url?(bI.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bT+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bW(bQ,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){s<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)bY(g,a[g],c,e);return d.join("&").replace(bz,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var b_=f.now(),ca=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+b_++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ca.test(b.url)||e&&ca.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ca,l),b.url===j&&(e&&(k=k.replace(ca,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cb=a.ActiveXObject?function(){for(var a in cd)cd[a](0,1)}:!1,cc=0,cd;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ce()||cf()}:ce,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cb&&delete cd[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cc,cb&&(cd||(cd={},f(a).unload(cb)),cd[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cg={},ch,ci,cj=/^(?:toggle|show|hide)$/,ck=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cl,cm=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cn;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cq("show",3),a,b,c);for(var g=0,h=this.length;g=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){for(var a=f.timers,b=0;b
    ";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),f.offset.initialize=f.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.offset.initialize(),f.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=ct.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!ct.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cu(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cu(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a&&a.style?parseFloat(f.css(a,d,"padding")):null},f.fn["outer"+c]=function(a){var b=this[0];return b&&b.style?parseFloat(f.css(b,d,a?"margin":"border")):null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNaN(j)?i:j}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window); \ No newline at end of file diff --git a/labs/architecture-examples/broke/libs/pyjammin.min.js b/labs/architecture-examples/broke/libs/pyjammin.min.js deleted file mode 100644 index 0dad5932f0..0000000000 --- a/labs/architecture-examples/broke/libs/pyjammin.min.js +++ /dev/null @@ -1,84 +0,0 @@ - -(function(__global__){var -getCallable=function(pathToProperty){var -tmpPath=pathToProperty.split('.'),path=tmpPath.slice(0,tmpPath.length-1).join('/'),property=tmpPath.slice(-1)[0];return require(path)[property];},all=function(arr){var arrLen=arr.length;while(arrLen--){if(!arr[arrLen]){return false;}} -return true;},any=function(arr){var arrLen=arr.length;while(arrLen--){if(arr[arrLen]){return true;}} -return false;},filter=function(arr,callback){var -result=[],arrLen=arr.length,i;for(i=0;i1){forEach(str,function(){if(obj!==undefined){obj=obj[this.concat()];}else{found=false;}});if(!found){return defaultResult;} -return obj;}else{return obj[str[0]]||defaultResult;}},str=function(obj){if(obj===undefined){return'';}else if(obj.__str__){return obj.__str__();} -return obj.toString();},repr=function(obj){return obj.__repr__?obj.__repr__():'';},len=function(obj){if(obj.length!==undefined){return obj.length;}else if(obj.__len__){return obj.__len__();} -return undefined;},curry=function(fn){var args=Array.prototype.slice.call(arguments);return function(){return fn.apply(this,args.concat(Array.prototype.slice.call(arguments)));};},partial=function(fn){var args=Array.prototype.slice.call(arguments);return function(){var -arg=0,i;for(i=0;i=0;} -return firsStr.toString().indexOf(secondStr)>=0;},interpolate=function(str,arr){var -tmp=str.split('%s');if(typeOf(arr)!="array"){arr=Array.prototype.slice.call(arguments).slice(1)} -for(var i=0;i<(tmp.length-1);i++){tmp[i]+=arr.shift();} -return tmp.join('');},last=function(arr,args){if(args){arr[arr.length-1]=args;return arr;} -return arr[arr.length-1];},indexOf=function(arr,obj){for(var i=0;i=0;},keys=(function(){if('keys'in __global__){return keys;} -return function(object){var results=[];forEach(object,function(key){results.push(key);});return results;};})(),formatDateChars={shortMonths:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],longMonths:['January','February','March','April','May','June','July','August','September','October','November','December'],shortDays:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],longDays:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']},formatDate=function(date,format){var -formatLength=format.length,i,curChar,returnStr='',replace={d:function(){return(date.getDate()<10?'0':'')+date.getDate();},D:function(){return formatDateChars.shortDays[date.getDay()];},j:function(){return date.getDate();},l:function(){return formatDateChars.longDays[date.getDay()];},N:function(){return date.getDay()+1;},S:function(){return(date.getDate()%10==1&&date.getDate()!=11?'st':(date.getDate()%10===2&&date.getDate()!=12?'nd':(date.getDate()%10==3&&date.getDate()!==13?'rd':'th')));},w:function(){return date.getDay();},z:function(){return"Not Yet Supported";},W:function(){return"Not Yet Supported";},F:function(){return formatDateChars.longMonths[date.getMonth()];},m:function(){return(date.getMonth()<9?'0':'')+(date.getMonth()+1);},M:function(){return formatDateChars.shortMonths[date.getMonth()];},n:function(){return date.getMonth()+1;},t:function(){return"Not Yet Supported";},L:function(){return(((date.getFullYear()%4===0)&&(date.getFullYear()%100!==0))||(date.getFullYear()%400===0))?'1':'0';},o:function(){return"Not Supported";},Y:function(){return date.getFullYear();},y:function(){return(''+date.getFullYear()).substr(2);},a:function(){return date.getHours()<12?'am':'pm';},A:function(){return date.getHours()<12?'AM':'PM';},B:function(){return"Not Yet Supported";},g:function(){return date.getHours()%12||12;},G:function(){return date.getHours();},h:function(){return((date.getHours()%12||12)<10?'0':'')+(date.getHours()%12||12);},H:function(){return(date.getHours()<10?'0':'')+date.getHours();},i:function(){return(date.getMinutes()<10?'0':'')+date.getMinutes();},s:function(){return(date.getSeconds()<10?'0':'')+date.getSeconds();},e:function(){return"Not Yet Supported";},I:function(){return"Not Supported";},O:function(){return(-date.getTimezoneOffset()<0?'-':'+')+(Math.abs(date.getTimezoneOffset()/60)<10?'0':'')+(Math.abs(date.getTimezoneOffset()/60))+'00';},P:function(){return(-date.getTimezoneOffset()<0?'-':'+')+(Math.abs(date.getTimezoneOffset()/60)<10?'0':'')+(Math.abs(date.getTimezoneOffset()/60))+':'+(Math.abs(date.getTimezoneOffset()%60)<10?'0':'')+(Math.abs(date.getTimezoneOffset()%60));},T:function(){var m=date.getMonth();date.setMonth(0);var result=date.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/,'$1');date.setMonth(m);return result;},Z:function(){return-date.getTimezoneOffset()*60;},c:function(){return formatDate(date,"Y-m-d")+"T"+formatDate(date,"H:i:sP");},r:function(){return date.toString();},U:function(){return date.getTime()/1000;}};for(i=0;i=index){rangeItem.push(index);index+=step;} -return rangeItem;},extend=function(){var -name,target=arguments[0]||{},i=1,length=arguments.length,deep=false,options,src,copy;if(arguments.length>2){extend.apply(this,arguments.slice(1));} -if(typeof target==="boolean"){deep=target;target=arguments[1]||{};i=2;} -if(typeof target!=="object"&&!(target instanceof Function)){target={};} -if(length==i){target=this;--i;} -while(i";},__str__:function(){return this.__repr__.apply(this,arguments);},__unicode__:function(){throw new NotImplemented()},toString:function(){return this.__repr__.apply(this,arguments);}},staticAttrs={__repr__:function(){return"";},toString:function(){return this.__repr__.apply(this,arguments);}},NotImplemented=new Error('Not implemented.'),klassInitializing=false,fnTest=/xyz/.test(function(){var xyz;})?/\b_super\b/:/.*/,Class=function(kwargs){return;};Class.create=function(kwargs){var -_super_class=this,_super=this.prototype,prototype,metaClass={},name,__class__,instanceInitializing=false;for(name in attrs){if(kwargs&&!kwargs.hasOwnProperty(name)){kwargs[name]=attrs[name];}} -__class__=function(){var -newMethod,newInstance,args=Array.prototype.slice.call(arguments),name,callableObject;args.unshift(__class__);if(!(this instanceof __class__)){newMethod=__class__.prototype.__new__;}else if(!instanceInitializing){newMethod=this.__new__;} -if(!(this instanceof __class__)||!instanceInitializing){instanceInitializing=true;newInstance=newMethod.apply(__class__,args);instanceInitializing=false;if(!klassInitializing&&newInstance.__init__&&newInstance instanceof __class__){newInstance.__init__.apply(newInstance,arguments);} -if(!newInstance.__call__){return newInstance;} -callableObject=function(){return newInstance.__call__.apply(newInstance,[this,callableObject].concat(Array.prototype.slice.call(arguments)));};for(name in newInstance){callableObject[name]=newInstance[name];} -return callableObject;}};klassInitializing=true;prototype=new this();klassInitializing=false;for(name in kwargs){if(kwargs.hasOwnProperty(name)){prototype[name]=(function(proto,name,kwargs){if(typeof kwargs[name]=="function"&&typeof _super[name]=="function"&&fnTest.test(kwargs[name])){return function(){var -tmp=this._super,ret;this._super=_super[name];ret=kwargs[name].apply(this,arguments);this._super=tmp;return ret;};}else{return kwargs[name];}})(prototype,name,kwargs);}} -__class__.prototype=prototype;__class__.prototype.__class__=__class__;__class__.constructor=__class__;for(name in this){if(this.hasOwnProperty(name)&&name!='prototype'){__class__[name]=this[name];}} -__class__.create=arguments.callee;if(kwargs&&kwargs.__name__){var -current=kwargs.__parent__||__global__,parts=kwargs.__name__.split(/\./);for(i=0;i' + - '{{ task.title }}' + - '' + - '' + - '' - ; - - todo.templates= { - list: '
      ' + - '{% for task in taskList %}' + - genericTaskTemplate + - '{% endfor %}' + - '
    ' - ,view: genericTaskTemplate - ,create: '' - ,update: '
  • '+ - '
    ' + - '' + - '
    ' + - '
  • ' - }; -})(this); \ No newline at end of file diff --git a/labs/architecture-examples/broke/project/urls.js b/labs/architecture-examples/broke/project/urls.js deleted file mode 100644 index 5b8e0d1b69..0000000000 --- a/labs/architecture-examples/broke/project/urls.js +++ /dev/null @@ -1,14 +0,0 @@ -(function(context, undefined){ - var - patterns= broke.conf.urls.defaults.patterns - ; - - todo.urls= patterns('todo.views', - [ '^/$', 'list' ] - ,[ '^/task/create/', 'create' ] - ,[ '^/task/update/([a-zA-Z0-9_-]+)/', 'update' ] - ,[ '^/task/delete/([a-zA-Z0-9_-]+)/', 'delete' ] - ,[ '^/task/complete/([a-zA-Z0-9_-]+)/', 'complete' ] - ,[ '^/task/clear_completed/', 'clear_completed' ] - ); -})(this); \ No newline at end of file diff --git a/labs/architecture-examples/broke/project/views.js b/labs/architecture-examples/broke/project/views.js deleted file mode 100644 index e2b5745a78..0000000000 --- a/labs/architecture-examples/broke/project/views.js +++ /dev/null @@ -1,110 +0,0 @@ -(function(context, undefined){ - var - node= broke.shortcuts.node - ,Task= todo.models.Task - ; - - todo.views= { - list: function(request, callback){ - - Task.objects.all(function(taskList){ - - callback(node.create({ - htmlNode: '#content' - ,template: 'list' - ,object: taskList - ,context: { - taskList: taskList - } - })); - - }); - - } - ,create: function(request, callback){ - - if(request.POST) { - - Task.objects.create({ - title: request.POST['title'] - ,pk: 'auto' - }, function(task){ - - callback(node.create({ - htmlNode: '#content .items' - ,template: 'view' - ,object: task - ,context: { - task: task - } - ,callback: function(){ - broke.DOM.val(request.event.target.title, ''); - } - })); - }); - } - - } - ,update: function(request, taskId, callback){ - - Task.objects.get({ pk: taskId }, function(task){ - - if(request.POST) { - - task.update({ title: request.POST['title'] }); - - callback(node.replace({ - template: 'view' - ,context: { - task: task - } - ,htmlNode: task.elements({ clearCache: true, filter: 'li' }) - })); - - } else { - - callback(node.replace({ - template: 'update' - ,context: { - task: task - } - ,htmlNode: task.elements({ clearCache: true, filter: 'li' }) - ,callback: function(){ - broke.DOM.querySelector('input', this)[0].focus(); - } - })); - - } - - }); - - } - ,'delete': function(request, taskId, callback){ - request.event.preventDefault(); - - Task.objects.get({ pk: taskId }, function(task){ - task['delete'](); - }); - } - ,complete: function(request, taskId, callback){ - - Task.objects.get({ pk: taskId }, function(task){ - - task.update({ is_complete: request.event.target.checked }, false); - - }); - - } - ,clear_completed: function(request, taskId, callback){ - - Task.objects.filter({ is_complete: true }).all(function(taskList){ - - builtins.forEach(taskList, function(task){ - this['delete'](); - }); - - }); - - } - }; -})(this); \ No newline at end of file diff --git a/readme.md b/readme.md index 389f05e6c3..08427e588b 100644 --- a/readme.md +++ b/readme.md @@ -61,7 +61,6 @@ We also have a number of in-progress applications in Labs: - [PlastronJS](https://github.com/rhysbrettbowen/PlastronJS) - [Dijon](https://github.com/creynders/dijon-framework) - [rAppid.js](http://www.rappidjs.com) -- [Broke](https://github.com/brokenseal/broke) - [o_O](http://weepy.github.com/o_O) - [Fun](https://github.com/marcuswestin/fun) - [KnockoutJS](http://knockoutjs.com) + [RequireJS](http://requirejs.org) (using AMD) @@ -141,4 +140,4 @@ For applications that we feel don't quite match the goals of the project, but wh ## License -[The Unlicense](unlicense.org) (i.e Public Domain) \ No newline at end of file +[The Unlicense](unlicense.org) (i.e Public Domain)